maplibre-gl 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,12 @@
8
8
 
9
9
  - *...Add new stuff here...*
10
10
 
11
+ ## 2.0.2
12
+
13
+ ### 🐞 Bug fixes
14
+
15
+ - Fix typescript generated file (#776).
16
+
11
17
  ## 2.0.1
12
18
 
13
19
  ### 🐞 Bug fixes
@@ -21,6 +27,7 @@
21
27
  - Migrated the production code to typescript
22
28
  - ** Breaking Change ** removed `version` from the public API
23
29
  - ** Breaking Change ** stopped supporting IE (internet explorer)
30
+ - ** Breaking Change ** stopped supporting Chrome 49-65. Chrome 66+ required. For Chrome 49-65 support use version 1.15.2.
24
31
  - ** Breaking Change ** removed all code related to `accessToken` and Mapbox specific urls starting with `mapbox://`. Telemetry and tracking code was removed.
25
32
  - ** Breaking Change ** removed `baseApiUrl` as it was used only for Mapbox related urls
26
33
  - ** Breaking Change ** typescript typings have changed:
@@ -87,7 +87,7 @@ function createStructArrayType(name: string, layout: StructArrayLayout, includeS
87
87
  includeStructAccessors
88
88
  });
89
89
  } else {
90
- arrayTypeEntries.add(`${layoutClass} as ${arrayClass}`);
90
+ arrayTypeEntries.add(`export class ${arrayClass} extends ${layoutClass} {}`);
91
91
  }
92
92
  }
93
93
 
@@ -432,8 +432,8 @@ import Point from '../util/point';
432
432
 
433
433
  ${layouts.map(emitStructArrayLayout).join('\n')}
434
434
  ${arraysWithStructAccessors.map(emitStructArray).join('\n')}
435
+ ${[...arrayTypeEntries].join('\n')}
435
436
  export {
436
- ${layouts.map(layout => layout.className).join(',\n ')},
437
- ${[...arrayTypeEntries].join(',\n ')}
437
+ ${layouts.map(layout => layout.className).join(',\n ')}
438
438
  };
439
439
  `);
@@ -35,7 +35,17 @@ console.log(`Starting bundling types`);
35
35
  const outputFile = "./dist/maplibre-gl.d.ts";
36
36
  child_process.execSync(`dts-bundle-generator --no-check --umd-module-name=maplibregl -o ${outputFile} ./src/index.ts`);
37
37
  let types = fs.readFileSync(outputFile, 'utf8');
38
+ // Classes are not exported but should be since this is exported as UMD - fixing...
38
39
  types = types.replace(/declare class/g, "export declare class");
40
+ // Missing vector-tile types that are added to this file too
41
+ let file = fs.readFileSync("./src/types/packages-types/vector-tile/index.d.ts", 'utf8');
42
+ let lines = file.split("\n").filter(Boolean);
43
+ lines.pop(); // last } is removed too.
44
+ types = lines.join("\n") + "\n" + types;
45
+ // remove imports of vector-tile and declare module lines
46
+ types = types.split("\n")
47
+ .filter(l => !l.includes("@mapbox/vector-tile"))
48
+ .join("\n");
39
49
  fs.writeFileSync(outputFile, types);
40
50
  console.log(`Finished bundling types`);
41
51
 
@@ -1,190 +1,30 @@
1
+ import type Pbf from 'pbf';
2
+ export class VectorTileLayer {
3
+ version?: number;
4
+ name: string;
5
+ extent: number;
6
+ length: number;
7
+ feature(i: number): VectorTileFeature;
8
+ }
9
+ export class VectorTile {
10
+ constructor(pbf: Pbf);
11
+ layers: {[_: string]: VectorTileLayer};
12
+ }
13
+ export class VectorTileFeature {
14
+ static types: ['Unknown', 'Point', 'LineString', 'Polygon'];
15
+ extent: number;
16
+ type: 1 | 2 | 3;
17
+ id: number;
18
+ properties: {[_: string]: string | number | boolean};
19
+ loadGeometry(): Array<Array<Point>>;
20
+ toGeoJSON(x: number, y: number, z: number): GeoJSON.Feature;
21
+ }
1
22
  // Generated by dts-bundle-generator v6.1.0
2
23
 
3
24
  import TinySDF from '@mapbox/tiny-sdf';
4
25
  import { mat2, mat4 } from 'gl-matrix';
5
26
  import { PotpackBox } from 'potpack';
6
27
 
7
- /**
8
- * A {@link Point} or an array of two numbers representing `x` and `y` screen coordinates in pixels.
9
- *
10
- * @typedef {(Point | [number, number])} PointLike
11
- * @example
12
- * var p1 = new maplibregl.Point(-77, 38); // a PointLike which is a Point
13
- * var p2 = [-77, 38]; // a PointLike which is an array of two numbers
14
- */
15
- export declare type PointLike = Point | [
16
- number,
17
- number
18
- ];
19
- export declare class Point {
20
- x: number;
21
- y: number;
22
- constructor(x: number, y: number);
23
- /**
24
- * Clone this point, returning a new point that can be modified
25
- * without affecting the old one.
26
- * @returns {Point} the clone
27
- */
28
- clone(): Point;
29
- /**
30
- * Add this point's x & y coordinates to another point,
31
- * yielding a new point.
32
- * @param {Point} p the other point
33
- * @returns {Point} output point
34
- */
35
- add(p: any): Point;
36
- /**
37
- * Subtract this point's x & y coordinates to from point,
38
- * yielding a new point.
39
- * @param {Point} p the other point
40
- * @returns {Point} output point
41
- */
42
- sub(p: any): Point;
43
- /**
44
- * Multiply this point's x & y coordinates by point,
45
- * yielding a new point.
46
- * @param {Point} p the other point
47
- * @returns {Point} output point
48
- */
49
- multByPoint(p: any): Point;
50
- /**
51
- * Divide this point's x & y coordinates by point,
52
- * yielding a new point.
53
- * @param {Point} p the other point
54
- * @returns {Point} output point
55
- */
56
- divByPoint(p: any): Point;
57
- /**
58
- * Multiply this point's x & y coordinates by a factor,
59
- * yielding a new point.
60
- * @param {Point} k factor
61
- * @returns {Point} output point
62
- */
63
- mult(k: any): Point;
64
- /**
65
- * Divide this point's x & y coordinates by a factor,
66
- * yielding a new point.
67
- * @param {Point} k factor
68
- * @returns {Point} output point
69
- */
70
- div(k: any): Point;
71
- /**
72
- * Rotate this point around the 0, 0 origin by an angle a,
73
- * given in radians
74
- * @param {Number} a angle to rotate around, in radians
75
- * @returns {Point} output point
76
- */
77
- rotate(a: any): Point;
78
- /**
79
- * Rotate this point around p point by an angle a,
80
- * given in radians
81
- * @param {Number} a angle to rotate around, in radians
82
- * @param {Point} p Point to rotate around
83
- * @returns {Point} output point
84
- */
85
- rotateAround(a: any, p: any): Point;
86
- /**
87
- * Multiply this point by a 4x1 transformation matrix
88
- * @param {Array<Number>} m transformation matrix
89
- * @returns {Point} output point
90
- */
91
- matMult(m: any): Point;
92
- /**
93
- * Calculate this point but as a unit vector from 0, 0, meaning
94
- * that the distance from the resulting point to the 0, 0
95
- * coordinate will be equal to 1 and the angle from the resulting
96
- * point to the 0, 0 coordinate will be the same as before.
97
- * @returns {Point} unit vector point
98
- */
99
- unit(): Point;
100
- /**
101
- * Compute a perpendicular point, where the new y coordinate
102
- * is the old x coordinate and the new x coordinate is the old y
103
- * coordinate multiplied by -1
104
- * @returns {Point} perpendicular point
105
- */
106
- perp(): Point;
107
- /**
108
- * Return a version of this point with the x & y coordinates
109
- * rounded to integers.
110
- * @returns {Point} rounded point
111
- */
112
- round(): Point;
113
- /**
114
- * Return the magitude of this point: this is the Euclidean
115
- * distance from the 0, 0 coordinate to this point's x and y
116
- * coordinates.
117
- * @returns {Number} magnitude
118
- */
119
- mag(): number;
120
- /**
121
- * Judge whether this point is equal to another point, returning
122
- * true or false.
123
- * @param {Point} other the other point
124
- * @returns {boolean} whether the points are equal
125
- */
126
- equals(other: any): boolean;
127
- /**
128
- * Calculate the distance from this point to another point
129
- * @param {Point} p the other point
130
- * @returns {Number} distance
131
- */
132
- dist(p: any): number;
133
- /**
134
- * Calculate the distance from this point to another point,
135
- * without the square root step. Useful if you're comparing
136
- * relative distances.
137
- * @param {Point} p the other point
138
- * @returns {Number} distance
139
- */
140
- distSqr(p: any): number;
141
- /**
142
- * Get the angle from the 0, 0 coordinate to this point, in radians
143
- * coordinates.
144
- * @returns {Number} angle
145
- */
146
- angle(): number;
147
- /**
148
- * Get the angle from this point to another point, in radians
149
- * @param {Point} b the other point
150
- * @returns {Number} angle
151
- */
152
- angleTo(b: any): number;
153
- /**
154
- * Get the angle between this point and another point, in radians
155
- * @param {Point} b the other point
156
- * @returns {Number} angle
157
- */
158
- angleWith(b: any): number;
159
- angleWithSep(x: any, y: any): number;
160
- _matMult(m: any): this;
161
- _add(p: any): this;
162
- _sub(p: any): this;
163
- _mult(k: any): this;
164
- _div(k: any): this;
165
- _multByPoint(p: any): this;
166
- _divByPoint(p: any): this;
167
- _unit(): this;
168
- _perp(): this;
169
- _rotate(angle: any): this;
170
- _rotateAround(angle: any, p: any): this;
171
- _round(): this;
172
- /**
173
- * Construct a point from an array if necessary, otherwise if the input
174
- * is already a Point, or an unknown type, return it unchanged
175
- * @param {Array<Number>|Point|*} a any kind of input value
176
- * @returns {Point} constructed point, or passed-through value.
177
- * @example
178
- * // this
179
- * var point = Point.convert([0, 1]);
180
- * // is equivalent to
181
- * var point = new Point(0, 1);
182
- */
183
- static convert(a: PointLike | {
184
- x: number;
185
- y: number;
186
- }): Point;
187
- }
188
28
  export declare type Callback<T> = (error?: Error | null, result?: T | null) => void;
189
29
  export declare type Cancelable = {
190
30
  cancel: () => void;
@@ -962,6 +802,187 @@ export declare class EvaluationParameters {
962
802
  crossFadingFactor(): number;
963
803
  getCrossfadeParameters(): CrossfadeParameters;
964
804
  }
805
+ /**
806
+ * A {@link Point} or an array of two numbers representing `x` and `y` screen coordinates in pixels.
807
+ *
808
+ * @typedef {(Point | [number, number])} PointLike
809
+ * @example
810
+ * var p1 = new maplibregl.Point(-77, 38); // a PointLike which is a Point
811
+ * var p2 = [-77, 38]; // a PointLike which is an array of two numbers
812
+ */
813
+ export declare type PointLike = Point | [
814
+ number,
815
+ number
816
+ ];
817
+ export declare class Point {
818
+ x: number;
819
+ y: number;
820
+ constructor(x: number, y: number);
821
+ /**
822
+ * Clone this point, returning a new point that can be modified
823
+ * without affecting the old one.
824
+ * @returns {Point} the clone
825
+ */
826
+ clone(): Point;
827
+ /**
828
+ * Add this point's x & y coordinates to another point,
829
+ * yielding a new point.
830
+ * @param {Point} p the other point
831
+ * @returns {Point} output point
832
+ */
833
+ add(p: any): Point;
834
+ /**
835
+ * Subtract this point's x & y coordinates to from point,
836
+ * yielding a new point.
837
+ * @param {Point} p the other point
838
+ * @returns {Point} output point
839
+ */
840
+ sub(p: any): Point;
841
+ /**
842
+ * Multiply this point's x & y coordinates by point,
843
+ * yielding a new point.
844
+ * @param {Point} p the other point
845
+ * @returns {Point} output point
846
+ */
847
+ multByPoint(p: any): Point;
848
+ /**
849
+ * Divide this point's x & y coordinates by point,
850
+ * yielding a new point.
851
+ * @param {Point} p the other point
852
+ * @returns {Point} output point
853
+ */
854
+ divByPoint(p: any): Point;
855
+ /**
856
+ * Multiply this point's x & y coordinates by a factor,
857
+ * yielding a new point.
858
+ * @param {Point} k factor
859
+ * @returns {Point} output point
860
+ */
861
+ mult(k: any): Point;
862
+ /**
863
+ * Divide this point's x & y coordinates by a factor,
864
+ * yielding a new point.
865
+ * @param {Point} k factor
866
+ * @returns {Point} output point
867
+ */
868
+ div(k: any): Point;
869
+ /**
870
+ * Rotate this point around the 0, 0 origin by an angle a,
871
+ * given in radians
872
+ * @param {Number} a angle to rotate around, in radians
873
+ * @returns {Point} output point
874
+ */
875
+ rotate(a: any): Point;
876
+ /**
877
+ * Rotate this point around p point by an angle a,
878
+ * given in radians
879
+ * @param {Number} a angle to rotate around, in radians
880
+ * @param {Point} p Point to rotate around
881
+ * @returns {Point} output point
882
+ */
883
+ rotateAround(a: any, p: any): Point;
884
+ /**
885
+ * Multiply this point by a 4x1 transformation matrix
886
+ * @param {Array<Number>} m transformation matrix
887
+ * @returns {Point} output point
888
+ */
889
+ matMult(m: any): Point;
890
+ /**
891
+ * Calculate this point but as a unit vector from 0, 0, meaning
892
+ * that the distance from the resulting point to the 0, 0
893
+ * coordinate will be equal to 1 and the angle from the resulting
894
+ * point to the 0, 0 coordinate will be the same as before.
895
+ * @returns {Point} unit vector point
896
+ */
897
+ unit(): Point;
898
+ /**
899
+ * Compute a perpendicular point, where the new y coordinate
900
+ * is the old x coordinate and the new x coordinate is the old y
901
+ * coordinate multiplied by -1
902
+ * @returns {Point} perpendicular point
903
+ */
904
+ perp(): Point;
905
+ /**
906
+ * Return a version of this point with the x & y coordinates
907
+ * rounded to integers.
908
+ * @returns {Point} rounded point
909
+ */
910
+ round(): Point;
911
+ /**
912
+ * Return the magitude of this point: this is the Euclidean
913
+ * distance from the 0, 0 coordinate to this point's x and y
914
+ * coordinates.
915
+ * @returns {Number} magnitude
916
+ */
917
+ mag(): number;
918
+ /**
919
+ * Judge whether this point is equal to another point, returning
920
+ * true or false.
921
+ * @param {Point} other the other point
922
+ * @returns {boolean} whether the points are equal
923
+ */
924
+ equals(other: any): boolean;
925
+ /**
926
+ * Calculate the distance from this point to another point
927
+ * @param {Point} p the other point
928
+ * @returns {Number} distance
929
+ */
930
+ dist(p: any): number;
931
+ /**
932
+ * Calculate the distance from this point to another point,
933
+ * without the square root step. Useful if you're comparing
934
+ * relative distances.
935
+ * @param {Point} p the other point
936
+ * @returns {Number} distance
937
+ */
938
+ distSqr(p: any): number;
939
+ /**
940
+ * Get the angle from the 0, 0 coordinate to this point, in radians
941
+ * coordinates.
942
+ * @returns {Number} angle
943
+ */
944
+ angle(): number;
945
+ /**
946
+ * Get the angle from this point to another point, in radians
947
+ * @param {Point} b the other point
948
+ * @returns {Number} angle
949
+ */
950
+ angleTo(b: any): number;
951
+ /**
952
+ * Get the angle between this point and another point, in radians
953
+ * @param {Point} b the other point
954
+ * @returns {Number} angle
955
+ */
956
+ angleWith(b: any): number;
957
+ angleWithSep(x: any, y: any): number;
958
+ _matMult(m: any): this;
959
+ _add(p: any): this;
960
+ _sub(p: any): this;
961
+ _mult(k: any): this;
962
+ _div(k: any): this;
963
+ _multByPoint(p: any): this;
964
+ _divByPoint(p: any): this;
965
+ _unit(): this;
966
+ _perp(): this;
967
+ _rotate(angle: any): this;
968
+ _rotateAround(angle: any, p: any): this;
969
+ _round(): this;
970
+ /**
971
+ * Construct a point from an array if necessary, otherwise if the input
972
+ * is already a Point, or an unknown type, return it unchanged
973
+ * @param {Array<Number>|Point|*} a any kind of input value
974
+ * @returns {Point} constructed point, or passed-through value.
975
+ * @example
976
+ * // this
977
+ * var point = Point.convert([0, 1]);
978
+ * // is equivalent to
979
+ * var point = new Point(0, 1);
980
+ */
981
+ static convert(a: PointLike | {
982
+ x: number;
983
+ y: number;
984
+ }): Point;
985
+ }
965
986
  export declare class LngLatBounds {
966
987
  _ne: LngLat;
967
988
  _sw: LngLat;
@@ -1995,6 +2016,30 @@ export declare class FeatureIndexArray extends StructArrayLayout1ul2ui8 {
1995
2016
  */
1996
2017
  get(index: number): FeatureIndexStruct;
1997
2018
  }
2019
+ export declare class CircleLayoutArray extends StructArrayLayout2i4 {
2020
+ }
2021
+ export declare class FillLayoutArray extends StructArrayLayout2i4 {
2022
+ }
2023
+ export declare class FillExtrusionLayoutArray extends StructArrayLayout2i4i12 {
2024
+ }
2025
+ export declare class LineLayoutArray extends StructArrayLayout2i4ub8 {
2026
+ }
2027
+ export declare class LineExtLayoutArray extends StructArrayLayout2f8 {
2028
+ }
2029
+ export declare class SymbolLayoutArray extends StructArrayLayout4i4ui4i24 {
2030
+ }
2031
+ export declare class SymbolDynamicLayoutArray extends StructArrayLayout3f12 {
2032
+ }
2033
+ export declare class SymbolOpacityArray extends StructArrayLayout1ul4 {
2034
+ }
2035
+ export declare class CollisionVertexArray extends StructArrayLayout2ub2f12 {
2036
+ }
2037
+ export declare class TriangleIndexArray extends StructArrayLayout3ui6 {
2038
+ }
2039
+ export declare class LineIndexArray extends StructArrayLayout2ui4 {
2040
+ }
2041
+ export declare class LineStripIndexArray extends StructArrayLayout1ui2 {
2042
+ }
1998
2043
  export declare type SerializedFeaturePositionMap = {
1999
2044
  ids: Float64Array;
2000
2045
  positions: Uint32Array;
@@ -2732,6 +2777,35 @@ export declare class ImageAtlas {
2732
2777
  patchUpdatedImages(imageManager: ImageManager, texture: Texture): void;
2733
2778
  patchUpdatedImage(position: ImagePosition, image: StyleImage, texture: Texture): void;
2734
2779
  }
2780
+ export declare type SerializedGrid = {
2781
+ buffer: ArrayBuffer;
2782
+ };
2783
+ export declare class TransferableGridIndex {
2784
+ cells: number[][];
2785
+ arrayBuffer: ArrayBuffer;
2786
+ d: number;
2787
+ keys: number[];
2788
+ bboxes: number[];
2789
+ n: number;
2790
+ extent: number;
2791
+ padding: number;
2792
+ scale: any;
2793
+ uid: number;
2794
+ min: number;
2795
+ max: number;
2796
+ constructor(extent: number | ArrayBuffer, n?: number, padding?: number);
2797
+ insert(key: number, x1: number, y1: number, x2: number, y2: number): void;
2798
+ _insertReadonly(): void;
2799
+ _insertCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number): void;
2800
+ query(x1: number, y1: number, x2: number, y2: number, intersectionTest?: Function): number[];
2801
+ _queryCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, result: any, seenUids: any, intersectionTest: Function): void;
2802
+ _forEachCell(x1: number, y1: number, x2: number, y2: number, fn: Function, arg1: any, arg2: any, intersectionTest: any): void;
2803
+ _convertFromCellCoord(x: any): number;
2804
+ _convertToCellCoord(x: any): number;
2805
+ toArrayBuffer(): ArrayBuffer;
2806
+ static serialize(grid: TransferableGridIndex, transferables?: Array<Transferable>): SerializedGrid;
2807
+ static deserialize(serialized: SerializedGrid): TransferableGridIndex;
2808
+ }
2735
2809
  export declare class DictionaryCoder {
2736
2810
  _stringToNumber: {
2737
2811
  [_: string]: number;
@@ -4489,10 +4563,6 @@ export interface CustomLayerInterface {
4489
4563
  */
4490
4564
  onRemove(map: Map, gl: WebGLRenderingContext): void;
4491
4565
  }
4492
- export interface StyleLayer {
4493
- queryRadius?(bucket: Bucket): number;
4494
- queryIntersectsFeature?(queryGeometry: Array<Point>, feature: VectorTileFeature, featureState: FeatureState, geometry: Array<Array<Point>>, zoom: number, transform: Transform, pixelsToTileUnits: number, pixelPosMatrix: mat4): boolean | number;
4495
- }
4496
4566
  declare abstract class StyleLayer extends Evented {
4497
4567
  id: string;
4498
4568
  metadata: unknown;
@@ -4512,6 +4582,8 @@ declare abstract class StyleLayer extends Evented {
4512
4582
  _featureFilter: FeatureFilter;
4513
4583
  readonly onAdd: ((map: Map) => void);
4514
4584
  readonly onRemove: ((map: Map) => void);
4585
+ queryRadius?(bucket: Bucket): number;
4586
+ queryIntersectsFeature?(queryGeometry: Array<Point>, feature: VectorTileFeature, featureState: FeatureState, geometry: Array<Array<Point>>, zoom: number, transform: Transform, pixelsToTileUnits: number, pixelPosMatrix: mat4): boolean | number;
4515
4587
  constructor(layer: LayerSpecification | CustomLayerInterface, properties: Readonly<{
4516
4588
  layout?: Properties<any>;
4517
4589
  paint?: Properties<any>;
@@ -5953,8 +6025,8 @@ export declare type SourceStatics = {
5953
6025
  export declare type SourceClass = {
5954
6026
  new (...args: any): Source;
5955
6027
  } & SourceStatics;
5956
- declare const getType: (name: string) => any;
5957
- declare const setType: (name: string, type: new (...args: any) => Source) => void;
6028
+ declare const getSourceType: (name: string) => any;
6029
+ declare const setSourceType: (name: string, type: new (...args: any) => Source) => void;
5958
6030
  export declare class TileCache {
5959
6031
  max: number;
5960
6032
  data: {