@deck.gl/mapbox 8.8.0-alpha.4 → 8.8.0-beta.1

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/dist/dist.dev.js CHANGED
@@ -103,7 +103,8 @@ return /******/ (function(modules) { // webpackBootstrap
103
103
  /*! no static exports found */
104
104
  /***/ (function(module, exports, __webpack_require__) {
105
105
 
106
- const MapboxUtils = __webpack_require__(/*! ./src */ "./src/index.ts");
106
+ const MapboxUtils = __webpack_require__(/*! ./src */ "./src/index.ts"); // @ts-ignore (2339) undefined property
107
+
107
108
 
108
109
  const deck = globalThis.deck || {}; // Check if peer dependencies are included
109
110
 
@@ -115,9 +116,9 @@ module.exports = Object.assign(deck, MapboxUtils);
115
116
 
116
117
  /***/ }),
117
118
 
118
- /***/ "./src/deck-utils.js":
119
+ /***/ "./src/deck-utils.ts":
119
120
  /*!***************************!*\
120
- !*** ./src/deck-utils.js ***!
121
+ !*** ./src/deck-utils.ts ***!
121
122
  \***************************/
122
123
  /*! exports provided: getDeckInstance, addLayer, removeLayer, updateLayer, drawLayer, getViewState */
123
124
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
@@ -143,17 +144,14 @@ function getDeckInstance({
143
144
  return map.__deck;
144
145
  }
145
146
 
146
- const customRender = deck && deck.props._customRender;
147
+ const customRender = deck?.props._customRender;
147
148
  const deckProps = {
148
149
  useDevicePixels: true,
149
- _customRender: () => {
150
- map.triggerRepaint();
150
+ _customRender: reason => {
151
+ map.triggerRepaint(); // customRender may be subscribed by DeckGL React component to update child props
152
+ // make sure it is still called
151
153
 
152
- if (customRender) {
153
- // customRender may be subscribed by DeckGL React component to update child props
154
- // make sure it is still called
155
- customRender();
156
- }
154
+ customRender?.(reason);
157
155
  },
158
156
  // TODO: import these defaults from a single source of truth
159
157
  parameters: {
@@ -165,10 +163,6 @@ function getDeckInstance({
165
163
  depthFunc: gl.LEQUAL,
166
164
  blendEquation: gl.FUNC_ADD
167
165
  },
168
- userData: {
169
- isExternal: false,
170
- mapboxLayers: new Set()
171
- },
172
166
  views: deck && deck.props.views || [new _deck_gl_core__WEBPACK_IMPORTED_MODULE_0__["MapView"]({
173
167
  id: 'mapbox'
174
168
  })]
@@ -179,8 +173,8 @@ function getDeckInstance({
179
173
  // block deck from setting the canvas size
180
174
  Object.assign(deckProps, {
181
175
  gl,
182
- width: false,
183
- height: false,
176
+ width: null,
177
+ height: null,
184
178
  touchAction: 'unset',
185
179
  viewState: getViewState(map)
186
180
  }); // If using the WebGLContext created by deck (React use case), we use deck's viewState to drive the map.
@@ -191,7 +185,7 @@ function getDeckInstance({
191
185
 
192
186
  if (deck) {
193
187
  deck.setProps(deckProps);
194
- deck.props.userData.isExternal = true;
188
+ deck.userData.isExternal = true;
195
189
  } else {
196
190
  deck = new _deck_gl_core__WEBPACK_IMPORTED_MODULE_0__["Deck"](deckProps);
197
191
  map.on('remove', () => {
@@ -200,19 +194,21 @@ function getDeckInstance({
200
194
  });
201
195
  }
202
196
 
203
- deck.props.userData.mapboxVersion = getMapboxVersion(map);
197
+ deck.userData.mapboxLayers = new Set();
198
+ deck.userData.mapboxVersion = getMapboxVersion(map);
204
199
  map.__deck = deck;
205
200
  map.on('render', () => {
201
+ // @ts-expect-error (2445) protected property
206
202
  if (deck.layerManager) afterRender(deck, map);
207
203
  });
208
204
  return deck;
209
205
  }
210
206
  function addLayer(deck, layer) {
211
- deck.props.userData.mapboxLayers.add(layer);
207
+ deck.userData.mapboxLayers.add(layer);
212
208
  updateLayers(deck);
213
209
  }
214
210
  function removeLayer(deck, layer) {
215
- deck.props.userData.mapboxLayers.delete(layer);
211
+ deck.userData.mapboxLayers.delete(layer);
216
212
  updateLayers(deck);
217
213
  }
218
214
  function updateLayer(deck, layer) {
@@ -221,14 +217,15 @@ function updateLayer(deck, layer) {
221
217
  function drawLayer(deck, map, layer) {
222
218
  let {
223
219
  currentViewport
224
- } = deck.props.userData;
220
+ } = deck.userData;
225
221
 
226
222
  if (!currentViewport) {
227
223
  // This is the first layer drawn in this render cycle.
228
224
  // Generate viewport from the current map state.
229
225
  currentViewport = getViewport(deck, map, true);
230
- deck.props.userData.currentViewport = currentViewport;
231
- }
226
+ deck.userData.currentViewport = currentViewport;
227
+ } // @ts-expect-error (2445) protected property
228
+
232
229
 
233
230
  if (!deck.layerManager) {
234
231
  return;
@@ -262,10 +259,12 @@ function getViewState(map) {
262
259
  function getMapboxVersion(map) {
263
260
  // parse mapbox version string
264
261
  let major = 0;
265
- let minor = 0;
262
+ let minor = 0; // @ts-ignore (2339) undefined property
266
263
 
267
- if (map.version) {
268
- [major, minor] = map.version.split('.').slice(0, 2).map(Number);
264
+ const version = map.version;
265
+
266
+ if (version) {
267
+ [major, minor] = version.split('.').slice(0, 2).map(Number);
269
268
  }
270
269
 
271
270
  return {
@@ -277,7 +276,7 @@ function getMapboxVersion(map) {
277
276
  function getViewport(deck, map, useMapboxProjection = true) {
278
277
  const {
279
278
  mapboxVersion
280
- } = deck.props.userData;
279
+ } = deck.userData;
281
280
  return new _deck_gl_core__WEBPACK_IMPORTED_MODULE_0__["WebMercatorViewport"](Object.assign({
282
281
  id: 'mapbox',
283
282
  x: 0,
@@ -299,12 +298,13 @@ function afterRender(deck, map) {
299
298
  const {
300
299
  mapboxLayers,
301
300
  isExternal
302
- } = deck.props.userData;
301
+ } = deck.userData;
303
302
 
304
303
  if (isExternal) {
305
304
  // Draw non-Mapbox layers
306
305
  const mapboxLayerIds = Array.from(mapboxLayers, layer => layer.id);
307
- const hasNonMapboxLayers = deck.props.layers.some(layer => !mapboxLayerIds.includes(layer.id));
306
+ const deckLayers = Object(_deck_gl_core__WEBPACK_IMPORTED_MODULE_0__["_flatten"])(deck.props.layers, Boolean);
307
+ const hasNonMapboxLayers = deckLayers.some(layer => layer && !mapboxLayerIds.includes(layer.id));
308
308
  let viewports = deck.getViewports();
309
309
  const mapboxViewportIdx = viewports.findIndex(vp => vp.id === 'mapbox');
310
310
  const hasNonMapboxViews = viewports.length > 1 || mapboxViewportIdx < 0;
@@ -324,7 +324,7 @@ function afterRender(deck, map) {
324
324
  } // End of render cycle, clear generated viewport
325
325
 
326
326
 
327
- deck.props.userData.currentViewport = null;
327
+ deck.userData.currentViewport = null;
328
328
  }
329
329
 
330
330
  function onMapMove(deck, map) {
@@ -340,13 +340,13 @@ function onMapMove(deck, map) {
340
340
  }
341
341
 
342
342
  function updateLayers(deck) {
343
- if (deck.props.userData.isExternal) {
343
+ if (deck.userData.isExternal) {
344
344
  return;
345
345
  }
346
346
 
347
347
  const layers = [];
348
348
  let layerIndex = 0;
349
- deck.props.userData.mapboxLayers.forEach(deckLayer => {
349
+ deck.userData.mapboxLayers.forEach(deckLayer => {
350
350
  const LayerType = deckLayer.props.type;
351
351
  const layer = new LayerType(deckLayer.props, {
352
352
  _offset: layerIndex++
@@ -369,7 +369,7 @@ function updateLayers(deck) {
369
369
 
370
370
  "use strict";
371
371
  __webpack_require__.r(__webpack_exports__);
372
- /* harmony import */ var _mapbox_layer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mapbox-layer */ "./src/mapbox-layer.js");
372
+ /* harmony import */ var _mapbox_layer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mapbox-layer */ "./src/mapbox-layer.ts");
373
373
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MapboxLayer", function() { return _mapbox_layer__WEBPACK_IMPORTED_MODULE_0__["default"]; });
374
374
 
375
375
  /* harmony import */ var _mapbox_overlay__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mapbox-overlay */ "./src/mapbox-overlay.ts");
@@ -380,9 +380,9 @@ __webpack_require__.r(__webpack_exports__);
380
380
 
381
381
  /***/ }),
382
382
 
383
- /***/ "./src/mapbox-layer.js":
383
+ /***/ "./src/mapbox-layer.ts":
384
384
  /*!*****************************!*\
385
- !*** ./src/mapbox-layer.js ***!
385
+ !*** ./src/mapbox-layer.ts ***!
386
386
  \*****************************/
387
387
  /*! exports provided: default */
388
388
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
@@ -390,11 +390,25 @@ __webpack_require__.r(__webpack_exports__);
390
390
  "use strict";
391
391
  __webpack_require__.r(__webpack_exports__);
392
392
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return MapboxLayer; });
393
- /* harmony import */ var _deck_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./deck-utils */ "./src/deck-utils.js");
393
+ /* harmony import */ var _deck_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./deck-utils */ "./src/deck-utils.ts");
394
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
395
+
394
396
 
395
397
  class MapboxLayer {
396
398
  /* eslint-disable no-this-before-super */
397
399
  constructor(props) {
400
+ _defineProperty(this, "id", void 0);
401
+
402
+ _defineProperty(this, "type", void 0);
403
+
404
+ _defineProperty(this, "renderingMode", void 0);
405
+
406
+ _defineProperty(this, "map", void 0);
407
+
408
+ _defineProperty(this, "deck", void 0);
409
+
410
+ _defineProperty(this, "props", void 0);
411
+
398
412
  if (!props.id) {
399
413
  throw new Error('Layer must have an unique id');
400
414
  }
@@ -420,7 +434,9 @@ class MapboxLayer {
420
434
  }
421
435
 
422
436
  onRemove() {
423
- Object(_deck_utils__WEBPACK_IMPORTED_MODULE_0__["removeLayer"])(this.deck, this);
437
+ if (this.deck) {
438
+ Object(_deck_utils__WEBPACK_IMPORTED_MODULE_0__["removeLayer"])(this.deck, this);
439
+ }
424
440
  }
425
441
 
426
442
  setProps(props) {
@@ -434,7 +450,7 @@ class MapboxLayer {
434
450
  }
435
451
  }
436
452
 
437
- render(gl, matrix) {
453
+ render() {
438
454
  Object(_deck_utils__WEBPACK_IMPORTED_MODULE_0__["drawLayer"])(this.deck, this.map, this);
439
455
  }
440
456
 
@@ -454,7 +470,7 @@ __webpack_require__.r(__webpack_exports__);
454
470
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return MapboxOverlay; });
455
471
  /* harmony import */ var _deck_gl_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @deck.gl/core */ "@deck.gl/core");
456
472
  /* harmony import */ var _deck_gl_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_deck_gl_core__WEBPACK_IMPORTED_MODULE_0__);
457
- /* harmony import */ var _deck_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./deck-utils */ "./src/deck-utils.js");
473
+ /* harmony import */ var _deck_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./deck-utils */ "./src/deck-utils.ts");
458
474
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
459
475
 
460
476
 
@@ -492,11 +508,12 @@ class MapboxOverlay {
492
508
  const deck = this._deck;
493
509
 
494
510
  if (deck) {
511
+ // @ts-ignore (2345) map is always defined if deck is
495
512
  deck.setProps({
496
513
  viewState: Object(_deck_utils__WEBPACK_IMPORTED_MODULE_1__["getViewState"])(this._map)
497
514
  }); // Redraw immediately if view state has changed
498
515
 
499
- deck.redraw(false);
516
+ deck.redraw();
500
517
  }
501
518
  });
502
519
 
@@ -515,11 +532,9 @@ class MapboxOverlay {
515
532
 
516
533
  switch (event.type) {
517
534
  case 'click':
518
- // Hack: because we do not listen to pointer down, perform picking now
519
- deck._lastPointerDownInfo = deck.pickObject({ ...mockEvent.offsetCenter,
520
- radius: deck.props.pickingRadius
521
- });
522
- mockEvent.tapCount = 1;
535
+ mockEvent.tapCount = 1; // Hack: because we do not listen to pointer down, perform picking now
536
+
537
+ deck._onPointerDown(mockEvent);
523
538
 
524
539
  deck._onEvent(mockEvent);
525
540
 
@@ -615,6 +630,7 @@ class MapboxOverlay {
615
630
  }
616
631
 
617
632
  this._deck?.finalize();
633
+ this._deck = undefined;
618
634
  this._map = undefined;
619
635
  this._container = undefined;
620
636
  }
@@ -626,19 +642,22 @@ class MapboxOverlay {
626
642
 
627
643
 
628
644
  pickObject(params) {
629
- return this._deck && this._deck.pickObject(params);
645
+ Object(_deck_gl_core__WEBPACK_IMPORTED_MODULE_0__["assert"])(this._deck);
646
+ return this._deck.pickObject(params);
630
647
  }
631
648
  /** Forwards the Deck.pickMultipleObjects method */
632
649
 
633
650
 
634
651
  pickMultipleObjects(params) {
635
- return this._deck && this._deck.pickMultipleObjects(params);
652
+ Object(_deck_gl_core__WEBPACK_IMPORTED_MODULE_0__["assert"])(this._deck);
653
+ return this._deck.pickMultipleObjects(params);
636
654
  }
637
655
  /** Forwards the Deck.pickObjects method */
638
656
 
639
657
 
640
658
  pickObjects(params) {
641
- return this._deck && this._deck.pickObjects(params);
659
+ Object(_deck_gl_core__WEBPACK_IMPORTED_MODULE_0__["assert"])(this._deck);
660
+ return this._deck.pickObjects(params);
642
661
  }
643
662
  /** Remove from map and releases all resources */
644
663
 
@@ -17,6 +17,8 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
17
17
  var _core = require("@deck.gl/core");
18
18
 
19
19
  function getDeckInstance(_ref) {
20
+ var _deck;
21
+
20
22
  var map = _ref.map,
21
23
  gl = _ref.gl,
22
24
  deck = _ref.deck;
@@ -25,15 +27,12 @@ function getDeckInstance(_ref) {
25
27
  return map.__deck;
26
28
  }
27
29
 
28
- var customRender = deck && deck.props._customRender;
30
+ var customRender = (_deck = deck) === null || _deck === void 0 ? void 0 : _deck.props._customRender;
29
31
  var deckProps = {
30
32
  useDevicePixels: true,
31
- _customRender: function _customRender() {
33
+ _customRender: function _customRender(reason) {
32
34
  map.triggerRepaint();
33
-
34
- if (customRender) {
35
- customRender();
36
- }
35
+ customRender === null || customRender === void 0 ? void 0 : customRender(reason);
37
36
  },
38
37
  parameters: {
39
38
  depthMask: true,
@@ -44,10 +43,6 @@ function getDeckInstance(_ref) {
44
43
  depthFunc: 515,
45
44
  blendEquation: 32774
46
45
  },
47
- userData: {
48
- isExternal: false,
49
- mapboxLayers: new Set()
50
- },
51
46
  views: deck && deck.props.views || [new _core.MapView({
52
47
  id: 'mapbox'
53
48
  })]
@@ -56,8 +51,8 @@ function getDeckInstance(_ref) {
56
51
  if (!deck || deck.props.gl === gl) {
57
52
  Object.assign(deckProps, {
58
53
  gl: gl,
59
- width: false,
60
- height: false,
54
+ width: null,
55
+ height: null,
61
56
  touchAction: 'unset',
62
57
  viewState: getViewState(map)
63
58
  });
@@ -68,7 +63,7 @@ function getDeckInstance(_ref) {
68
63
 
69
64
  if (deck) {
70
65
  deck.setProps(deckProps);
71
- deck.props.userData.isExternal = true;
66
+ deck.userData.isExternal = true;
72
67
  } else {
73
68
  deck = new _core.Deck(deckProps);
74
69
  map.on('remove', function () {
@@ -77,7 +72,8 @@ function getDeckInstance(_ref) {
77
72
  });
78
73
  }
79
74
 
80
- deck.props.userData.mapboxVersion = getMapboxVersion(map);
75
+ deck.userData.mapboxLayers = new Set();
76
+ deck.userData.mapboxVersion = getMapboxVersion(map);
81
77
  map.__deck = deck;
82
78
  map.on('render', function () {
83
79
  if (deck.layerManager) afterRender(deck, map);
@@ -86,12 +82,12 @@ function getDeckInstance(_ref) {
86
82
  }
87
83
 
88
84
  function addLayer(deck, layer) {
89
- deck.props.userData.mapboxLayers.add(layer);
85
+ deck.userData.mapboxLayers.add(layer);
90
86
  updateLayers(deck);
91
87
  }
92
88
 
93
89
  function removeLayer(deck, layer) {
94
- deck.props.userData.mapboxLayers.delete(layer);
90
+ deck.userData.mapboxLayers.delete(layer);
95
91
  updateLayers(deck);
96
92
  }
97
93
 
@@ -100,11 +96,12 @@ function updateLayer(deck, layer) {
100
96
  }
101
97
 
102
98
  function drawLayer(deck, map, layer) {
103
- var currentViewport = deck.props.userData.currentViewport;
99
+ var _ref2 = deck.userData,
100
+ currentViewport = _ref2.currentViewport;
104
101
 
105
102
  if (!currentViewport) {
106
103
  currentViewport = getViewport(deck, map, true);
107
- deck.props.userData.currentViewport = currentViewport;
104
+ deck.userData.currentViewport = currentViewport;
108
105
  }
109
106
 
110
107
  if (!deck.layerManager) {
@@ -113,8 +110,8 @@ function drawLayer(deck, map, layer) {
113
110
 
114
111
  deck._drawLayers('mapbox-repaint', {
115
112
  viewports: [currentViewport],
116
- layerFilter: function layerFilter(_ref2) {
117
- var deckLayer = _ref2.layer;
113
+ layerFilter: function layerFilter(_ref3) {
114
+ var deckLayer = _ref3.layer;
118
115
  return layer.id === deckLayer.id;
119
116
  },
120
117
  clearCanvas: false
@@ -139,14 +136,15 @@ function getViewState(map) {
139
136
  function getMapboxVersion(map) {
140
137
  var major = 0;
141
138
  var minor = 0;
139
+ var version = map.version;
142
140
 
143
- if (map.version) {
144
- var _map$version$split$sl = map.version.split('.').slice(0, 2).map(Number);
141
+ if (version) {
142
+ var _version$split$slice$ = version.split('.').slice(0, 2).map(Number);
145
143
 
146
- var _map$version$split$sl2 = (0, _slicedToArray2.default)(_map$version$split$sl, 2);
144
+ var _version$split$slice$2 = (0, _slicedToArray2.default)(_version$split$slice$, 2);
147
145
 
148
- major = _map$version$split$sl2[0];
149
- minor = _map$version$split$sl2[1];
146
+ major = _version$split$slice$2[0];
147
+ minor = _version$split$slice$2[1];
150
148
  }
151
149
 
152
150
  return {
@@ -157,7 +155,8 @@ function getMapboxVersion(map) {
157
155
 
158
156
  function getViewport(deck, map) {
159
157
  var useMapboxProjection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
160
- var mapboxVersion = deck.props.userData.mapboxVersion;
158
+ var _ref4 = deck.userData,
159
+ mapboxVersion = _ref4.mapboxVersion;
161
160
  return new _core.WebMercatorViewport(Object.assign({
162
161
  id: 'mapbox',
163
162
  x: 0,
@@ -172,16 +171,17 @@ function getViewport(deck, map) {
172
171
  }
173
172
 
174
173
  function afterRender(deck, map) {
175
- var _deck$props$userData = deck.props.userData,
176
- mapboxLayers = _deck$props$userData.mapboxLayers,
177
- isExternal = _deck$props$userData.isExternal;
174
+ var _ref5 = deck.userData,
175
+ mapboxLayers = _ref5.mapboxLayers,
176
+ isExternal = _ref5.isExternal;
178
177
 
179
178
  if (isExternal) {
180
179
  var mapboxLayerIds = Array.from(mapboxLayers, function (layer) {
181
180
  return layer.id;
182
181
  });
183
- var hasNonMapboxLayers = deck.props.layers.some(function (layer) {
184
- return !mapboxLayerIds.includes(layer.id);
182
+ var deckLayers = (0, _core._flatten)(deck.props.layers, Boolean);
183
+ var hasNonMapboxLayers = deckLayers.some(function (layer) {
184
+ return layer && !mapboxLayerIds.includes(layer.id);
185
185
  });
186
186
  var viewports = deck.getViewports();
187
187
  var mapboxViewportIdx = viewports.findIndex(function (vp) {
@@ -205,7 +205,7 @@ function afterRender(deck, map) {
205
205
  }
206
206
  }
207
207
 
208
- deck.props.userData.currentViewport = null;
208
+ deck.userData.currentViewport = null;
209
209
  }
210
210
 
211
211
  function onMapMove(deck, map) {
@@ -218,13 +218,13 @@ function onMapMove(deck, map) {
218
218
  }
219
219
 
220
220
  function updateLayers(deck) {
221
- if (deck.props.userData.isExternal) {
221
+ if (deck.userData.isExternal) {
222
222
  return;
223
223
  }
224
224
 
225
225
  var layers = [];
226
226
  var layerIndex = 0;
227
- deck.props.userData.mapboxLayers.forEach(function (deckLayer) {
227
+ deck.userData.mapboxLayers.forEach(function (deckLayer) {
228
228
  var LayerType = deckLayer.props.type;
229
229
  var layer = new LayerType(deckLayer.props, {
230
230
  _offset: layerIndex++
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/deck-utils.js"],"names":["getDeckInstance","map","gl","deck","__deck","customRender","props","_customRender","deckProps","useDevicePixels","triggerRepaint","parameters","depthMask","depthTest","blend","blendFunc","polygonOffsetFill","depthFunc","blendEquation","userData","isExternal","mapboxLayers","Set","views","MapView","id","Object","assign","width","height","touchAction","viewState","getViewState","on","onMapMove","setProps","Deck","finalize","mapboxVersion","getMapboxVersion","layerManager","afterRender","addLayer","layer","add","updateLayers","removeLayer","delete","updateLayer","drawLayer","currentViewport","getViewport","_drawLayers","viewports","layerFilter","deckLayer","clearCanvas","getCenter","lng","lat","longitude","latitude","zoom","getZoom","bearing","getBearing","pitch","getPitch","repeat","getRenderWorldCopies","major","minor","version","split","slice","Number","useMapboxProjection","WebMercatorViewport","x","y","nearZMultiplier","mapboxLayerIds","Array","from","hasNonMapboxLayers","layers","some","includes","getViewports","mapboxViewportIdx","findIndex","vp","hasNonMapboxViews","length","params","viewport","needsRedraw","clearRedrawFlags","layerIndex","forEach","LayerType","type","_offset","push"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AAEO,SAASA,eAAT,OAA0C;AAAA,MAAhBC,GAAgB,QAAhBA,GAAgB;AAAA,MAAXC,EAAW,QAAXA,EAAW;AAAA,MAAPC,IAAO,QAAPA,IAAO;;AAE/C,MAAIF,GAAG,CAACG,MAAR,EAAgB;AACd,WAAOH,GAAG,CAACG,MAAX;AACD;;AAED,MAAMC,YAAY,GAAGF,IAAI,IAAIA,IAAI,CAACG,KAAL,CAAWC,aAAxC;AAEA,MAAMC,SAAS,GAAG;AAChBC,IAAAA,eAAe,EAAE,IADD;AAEhBF,IAAAA,aAAa,EAAE,yBAAM;AACnBN,MAAAA,GAAG,CAACS,cAAJ;;AACA,UAAIL,YAAJ,EAAkB;AAGhBA,QAAAA,YAAY;AACb;AACF,KATe;AAWhBM,IAAAA,UAAU,EAAE;AACVC,MAAAA,SAAS,EAAE,IADD;AAEVC,MAAAA,SAAS,EAAE,IAFD;AAGVC,MAAAA,KAAK,EAAE,IAHG;AAIVC,MAAAA,SAAS,EAAE,kBAJD;AAKVC,MAAAA,iBAAiB,EAAE,IALT;AAMVC,MAAAA,SAAS,KANC;AAOVC,MAAAA,aAAa;AAPH,KAXI;AAoBhBC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,UAAU,EAAE,KADJ;AAERC,MAAAA,YAAY,EAAE,IAAIC,GAAJ;AAFN,KApBM;A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tB,EAA4B;AAC1B,MAAIA,IAAI,CAACG,KAAL,CAAWa,QAAX,CAAoBC,UAAxB,EAAoC;AAClC;AACD;;AAED,MAAMiE,MAAM,GAAG,EAAf;AACA,MAAIa,UAAU,GAAG,CAAjB;AACA/F,EAAAA,IAAI,CAACG,KAAL,CAAWa,QAAX,CAAoBE,YAApB,CAAiC8E,OAAjC,CAAyC,UAAA5C,SAAS,EAAI;AACpD,QAAM6C,SAAS,GAAG7C,SAAS,CAACjD,KAAV,CAAgB+F,IAAlC;AACA,QAAM1D,KAAK,GAAG,IAAIyD,SAAJ,CAAc7C,SAAS,CAACjD,KAAxB,EAA+B;AAACgG,MAAAA,OAAO,EAAEJ,UAAU;AAApB,KAA/B,CAAd;AACAb,IAAAA,MAAM,CAACkB,IAAP,CAAY5D,KAAZ;AACD,GAJD;AAKAxC,EAAAA,IAAI,CAACgC,QAAL,CAAc;AAACkD,IAAAA,MAAM,EAANA;AAAD,GAAd;AACD","sourcesContent":["import {Deck, WebMercatorViewport, MapView} from '@deck.gl/core';\n\nexport function getDeckInstance({map, gl, deck}) {\n // Only create one deck instance per context\n if (map.__deck) {\n return map.__deck;\n }\n\n const customRender = deck && deck.props._customRender;\n\n const deckProps = {\n useDevicePixels: true,\n _customRender: () => {\n map.triggerRepaint();\n if (customRender) {\n // customRender may be subscribed by DeckGL React component to update child props\n // make sure it is still called\n customRender();\n }\n },\n // TODO: import these defaults from a single source of truth\n parameters: {\n depthMask: true,\n depthTest: true,\n blend: true,\n blendFunc: [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA],\n polygonOffsetFill: true,\n depthFunc: gl.LEQUAL,\n blendEquation: gl.FUNC_ADD\n },\n userData: {\n isExternal: false,\n mapboxLayers: new Set()\n },\n views: (deck && deck.props.views) || [new MapView({id: 'mapbox'})]\n };\n\n if (!deck || deck.props.gl === gl) {\n // deck is using the WebGLContext created by mapbox\n // block deck from setting the canvas size\n Object.assign(deckProps, {\n gl,\n width: false,\n height: false,\n touchAction: 'unset',\n viewState: getViewState(map)\n });\n // If using the WebGLContext created by deck (React use case), we use deck's viewState to drive the map.\n // Otherwise (pure JS use case), we use the map's viewState to drive deck.\n map.on('move', () => onMapMove(deck, map));\n }\n\n if (deck) {\n deck.setProps(deckProps);\n deck.props.userData.isExternal = true;\n } else {\n deck = new Deck(deckProps);\n map.on('remove', () => {\n deck.finalize();\n map.__deck = null;\n });\n }\n\n deck.props.userData.mapboxVersion = getMapboxVersion(map);\n map.__deck = deck;\n map.on('render', () => {\n if (deck.layerManager) afterRender(deck, map);\n });\n\n return deck;\n}\n\nexport function addLayer(deck, layer) {\n deck.props.userData.mapboxLayers.add(layer);\n updateLayers(deck);\n}\n\nexport function removeLayer(deck, layer) {\n deck.props.userData.mapboxLayers.delete(layer);\n updateLayers(deck);\n}\n\nexport function updateLayer(deck, layer) {\n updateLayers(deck);\n}\n\nexport function drawLayer(deck, map, layer) {\n let {currentViewport} = deck.props.userData;\n if (!currentViewport) {\n // This is the first layer drawn in this render cycle.\n // Generate viewport from the current map state.\n currentViewport = getViewport(deck, map, true);\n deck.props.userData.currentViewport = currentViewport;\n }\n if (!deck.layerManager) {\n return;\n }\n\n deck._drawLayers('mapbox-repaint', {\n viewports: [currentViewport],\n layerFilter: ({layer: deckLayer}) => layer.id === deckLayer.id,\n clearCanvas: false\n });\n}\n\nexport function getViewState(map) {\n const {lng, lat} = map.getCenter();\n return {\n // Longitude returned by getCenter can be outside of [-180, 180] when zooming near the anti meridian\n // https://github.com/visgl/deck.gl/issues/6894\n longitude: ((lng + 540) % 360) - 180,\n latitude: lat,\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch(),\n repeat: map.getRenderWorldCopies()\n };\n}\n\nfunction getMapboxVersion(map) {\n // parse mapbox version string\n let major = 0;\n let minor = 0;\n if (map.version) {\n [major, minor] = map.version.split('.').slice(0, 2).map(Number);\n }\n return {major, minor};\n}\n\nfunction getViewport(deck, map, useMapboxProjection = true) {\n const {mapboxVersion} = deck.props.userData;\n\n return new WebMercatorViewport(\n Object.assign(\n {\n id: 'mapbox',\n x: 0,\n y: 0,\n width: deck.width,\n height: deck.height\n },\n getViewState(map),\n useMapboxProjection\n ? {\n // match mapbox's projection matrix\n // A change of near plane was made in 1.3.0\n // https://github.com/mapbox/mapbox-gl-js/pull/8502\n nearZMultiplier:\n (mapboxVersion.major === 1 && mapboxVersion.minor >= 3) || mapboxVersion.major >= 2\n ? 0.02\n : 1 / (deck.height || 1)\n }\n : {\n // use deck.gl's own default\n nearZMultiplier: 0.1\n }\n )\n );\n}\n\nfunction afterRender(deck, map) {\n const {mapboxLayers, isExternal} = deck.props.userData;\n\n if (isExternal) {\n // Draw non-Mapbox layers\n const mapboxLayerIds = Array.from(mapboxLayers, layer => layer.id);\n const hasNonMapboxLayers = deck.props.layers.some(layer => !mapboxLayerIds.includes(layer.id));\n let viewports = deck.getViewports();\n const mapboxViewportIdx = viewports.findIndex(vp => vp.id === 'mapbox');\n const hasNonMapboxViews = viewports.length > 1 || mapboxViewportIdx < 0;\n\n if (hasNonMapboxLayers || hasNonMapboxViews) {\n if (mapboxViewportIdx >= 0) {\n viewports = viewports.slice();\n viewports[mapboxViewportIdx] = getViewport(deck, map, false);\n }\n\n deck._drawLayers('mapbox-repaint', {\n viewports,\n layerFilter: params =>\n (!deck.props.layerFilter || deck.props.layerFilter(params)) &&\n (params.viewport.id !== 'mapbox' || !mapboxLayerIds.includes(params.layer.id)),\n clearCanvas: false\n });\n }\n }\n\n // End of render cycle, clear generated viewport\n deck.props.userData.currentViewport = null;\n}\n\nfunction onMapMove(deck, map) {\n deck.setProps({\n viewState: getViewState(map)\n });\n // Camera changed, will trigger a map repaint right after this\n // Clear any change flag triggered by setting viewState so that deck does not request\n // a second repaint\n deck.needsRedraw({clearRedrawFlags: true});\n}\n\nfunction updateLayers(deck) {\n if (deck.props.userData.isExternal) {\n return;\n }\n\n const layers = [];\n let layerIndex = 0;\n deck.props.userData.mapboxLayers.forEach(deckLayer => {\n const LayerType = deckLayer.props.type;\n const layer = new LayerType(deckLayer.props, {_offset: layerIndex++});\n layers.push(layer);\n });\n deck.setProps({layers});\n}\n"],"file":"deck-utils.js"}
1
+ {"version":3,"sources":["../../src/deck-utils.ts"],"names":["getDeckInstance","map","gl","deck","__deck","customRender","props","_customRender","deckProps","useDevicePixels","reason","triggerRepaint","parameters","depthMask","depthTest","blend","blendFunc","polygonOffsetFill","depthFunc","blendEquation","views","MapView","id","Object","assign","width","height","touchAction","viewState","getViewState","on","onMapMove","setProps","userData","isExternal","Deck","finalize","mapboxLayers","Set","mapboxVersion","getMapboxVersion","layerManager","afterRender","addLayer","layer","add","updateLayers","removeLayer","delete","updateLayer","drawLayer","currentViewport","getViewport","_drawLayers","viewports","layerFilter","deckLayer","clearCanvas","getCenter","lng","lat","longitude","latitude","zoom","getZoom","bearing","getBearing","pitch","getPitch","repeat","getRenderWorldCopies","major","minor","version","split","slice","Number","useMapboxProjection","WebMercatorViewport","x","y","nearZMultiplier","mapboxLayerIds","Array","from","deckLayers","layers","Boolean","hasNonMapboxLayers","some","includes","getViewports","mapboxViewportIdx","findIndex","vp","hasNonMapboxViews","length","params","viewport","needsRedraw","clearRedrawFlags","layerIndex","forEach","LayerType","type","_offset","push"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AAYO,SAASA,eAAT,OAQE;AAAA;;AAAA,MAPPC,GAOO,QAPPA,GAOO;AAAA,MANPC,EAMO,QANPA,EAMO;AAAA,MALPC,IAKO,QALPA,IAKO;;AAEP,MAAIF,GAAG,CAACG,MAAR,EAAgB;AACd,WAAOH,GAAG,CAACG,MAAX;AACD;;AAED,MAAMC,YAAY,YAAGF,IAAH,0CAAG,MAAMG,KAAN,CAAYC,aAAjC;AAEA,MAAMC,SAAoB,GAAG;AAC3BC,IAAAA,eAAe,EAAE,IADU;AAE3BF,IAAAA,aAAa,EAAE,uBAACG,MAAD,EAAoB;AACjCT,MAAAA,G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CAAatB,EAArC,CADrC,CADiB;AAAA,SAFc;AAKjCmC,QAAAA,WAAW,EAAE;AALoB,OAAnC;AAOD;AACF;;AAGAtD,EAAAA,IAAI,CAAC8B,QAAN,CAA4BkB,eAA5B,GAA8C,IAA9C;AACD;;AAED,SAASpB,SAAT,CAAmB5B,IAAnB,EAA+BF,GAA/B,EAA+C;AAC7CE,EAAAA,IAAI,CAAC6B,QAAL,CAAc;AACZJ,IAAAA,SAAS,EAAEC,YAAY,CAAC5B,GAAD;AADX,GAAd;AAMAE,EAAAA,IAAI,CAACgG,WAAL,CAAiB;AAACC,IAAAA,gBAAgB,EAAE;AAAnB,GAAjB;AACD;;AAED,SAAStD,YAAT,CAAsB3C,IAAtB,EAAwC;AACtC,MAAKA,IAAI,CAAC8B,QAAN,CAA4BC,UAAhC,EAA4C;AAC1C;AACD;;AAED,MAAMoD,MAAe,GAAG,EAAxB;AACA,MAAIe,UAAU,GAAG,CAAjB;AACClG,EAAAA,IAAI,CAAC8B,QAAN,CAA4BI,YAA5B,CAAyCiE,OAAzC,CAAiD,UAAA9C,SAAS,EAAI;AAC5D,QAAM+C,SAAS,GAAG/C,SAAS,CAAClD,KAAV,CAAgBkG,IAAlC;AACA,QAAM5D,KAAK,GAAG,IAAI2D,SAAJ,CAAc/C,SAAS,CAAClD,KAAxB,EAA+B;AAACmG,MAAAA,OAAO,EAAEJ,UAAU;AAApB,KAA/B,CAAd;AACAf,IAAAA,MAAM,CAACoB,IAAP,CAAY9D,KAAZ;AACD,GAJD;AAKAzC,EAAAA,IAAI,CAAC6B,QAAL,CAAc;AAACsD,IAAAA,MAAM,EAANA;AAAD,GAAd;AACD","sourcesContent":["import {Deck, WebMercatorViewport, MapView, _flatten as flatten} from '@deck.gl/core';\nimport type {DeckProps, MapViewState, Layer} from '@deck.gl/core';\nimport type MapboxLayer from './mapbox-layer';\nimport type {Map} from 'mapbox-gl';\n\ntype UserData = {\n isExternal: boolean;\n currentViewport?: WebMercatorViewport | null;\n mapboxLayers: Set<MapboxLayer<any>>;\n mapboxVersion: {minor: number; major: number};\n};\n\nexport function getDeckInstance({\n map,\n gl,\n deck\n}: {\n map: Map & {__deck?: Deck | null};\n gl: WebGLRenderingContext;\n deck?: Deck;\n}): Deck {\n // Only create one deck instance per context\n if (map.__deck) {\n return map.__deck;\n }\n\n const customRender = deck?.props._customRender;\n\n const deckProps: DeckProps = {\n useDevicePixels: true,\n _customRender: (reason: string) => {\n map.triggerRepaint();\n // customRender may be subscribed by DeckGL React component to update child props\n // make sure it is still called\n customRender?.(reason);\n },\n // TODO: import these defaults from a single source of truth\n parameters: {\n depthMask: true,\n depthTest: true,\n blend: true,\n blendFunc: [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA],\n polygonOffsetFill: true,\n depthFunc: gl.LEQUAL,\n blendEquation: gl.FUNC_ADD\n },\n views: (deck && deck.props.views) || [new MapView({id: 'mapbox'})]\n };\n\n if (!deck || deck.props.gl === gl) {\n // deck is using the WebGLContext created by mapbox\n // block deck from setting the canvas size\n Object.assign(deckProps, {\n gl,\n width: null,\n height: null,\n touchAction: 'unset',\n viewState: getViewState(map)\n });\n // If using the WebGLContext created by deck (React use case), we use deck's viewState to drive the map.\n // Otherwise (pure JS use case), we use the map's viewState to drive deck.\n map.on('move', () => onMapMove(deck!, map));\n }\n\n if (deck) {\n deck.setProps(deckProps);\n (deck.userData as UserData).isExternal = true;\n } else {\n deck = new Deck(deckProps);\n map.on('remove', () => {\n deck!.finalize();\n map.__deck = null;\n });\n }\n\n (deck.userData as UserData).mapboxLayers = new Set();\n (deck.userData as UserData).mapboxVersion = getMapboxVersion(map);\n map.__deck = deck;\n map.on('render', () => {\n // @ts-expect-error (2445) protected property\n if (deck.layerManager) afterRender(deck, map);\n });\n\n return deck;\n}\n\nexport function addLayer(deck: Deck, layer: MapboxLayer<any>): void {\n (deck.userData as UserData).mapboxLayers.add(layer);\n updateLayers(deck);\n}\n\nexport function removeLayer(deck: Deck, layer: MapboxLayer<any>): void {\n (deck.userData as UserData).mapboxLayers.delete(layer);\n updateLayers(deck);\n}\n\nexport function updateLayer(deck: Deck, layer: MapboxLayer<any>): void {\n updateLayers(deck);\n}\n\nexport function drawLayer(deck: Deck, map: Map, layer: MapboxLayer<any>): void {\n let {currentViewport} = deck.userData as UserData;\n if (!currentViewport) {\n // This is the first layer drawn in this render cycle.\n // Generate viewport from the current map state.\n currentViewport = getViewport(deck, map, true);\n (deck.userData as UserData).currentViewport = currentViewport;\n }\n\n // @ts-expect-error (2445) protected property\n if (!deck.layerManager) {\n return;\n }\n\n deck._drawLayers('mapbox-repaint', {\n viewports: [currentViewport],\n layerFilter: ({layer: deckLayer}) => layer.id === deckLayer.id,\n clearCanvas: false\n });\n}\n\nexport function getViewState(map: Map): MapViewState & {repeat: boolean} {\n const {lng, lat} = map.getCenter();\n return {\n // Longitude returned by getCenter can be outside of [-180, 180] when zooming near the anti meridian\n // https://github.com/visgl/deck.gl/issues/6894\n longitude: ((lng + 540) % 360) - 180,\n latitude: lat,\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch(),\n repeat: map.getRenderWorldCopies()\n };\n}\n\nfunction getMapboxVersion(map: Map): {minor: number; major: number} {\n // parse mapbox version string\n let major = 0;\n let minor = 0;\n // @ts-ignore (2339) undefined property\n const version: string = map.version;\n if (version) {\n [major, minor] = version.split('.').slice(0, 2).map(Number);\n }\n return {major, minor};\n}\n\nfunction getViewport(deck: Deck, map: Map, useMapboxProjection = true): WebMercatorViewport {\n const {mapboxVersion} = deck.userData as UserData;\n\n return new WebMercatorViewport(\n Object.assign(\n {\n id: 'mapbox',\n x: 0,\n y: 0,\n width: deck.width,\n height: deck.height\n },\n getViewState(map),\n useMapboxProjection\n ? {\n // match mapbox's projection matrix\n // A change of near plane was made in 1.3.0\n // https://github.com/mapbox/mapbox-gl-js/pull/8502\n nearZMultiplier:\n (mapboxVersion.major === 1 && mapboxVersion.minor >= 3) || mapboxVersion.major >= 2\n ? 0.02\n : 1 / (deck.height || 1)\n }\n : {\n // use deck.gl's own default\n nearZMultiplier: 0.1\n }\n )\n );\n}\n\nfunction afterRender(deck: Deck, map: Map): void {\n const {mapboxLayers, isExternal} = deck.userData as UserData;\n\n if (isExternal) {\n // Draw non-Mapbox layers\n const mapboxLayerIds = Array.from(mapboxLayers, layer => layer.id);\n const deckLayers = flatten(deck.props.layers, Boolean) as Layer[];\n const hasNonMapboxLayers = deckLayers.some(\n layer => layer && !mapboxLayerIds.includes(layer.id)\n );\n let viewports = deck.getViewports();\n const mapboxViewportIdx = viewports.findIndex(vp => vp.id === 'mapbox');\n const hasNonMapboxViews = viewports.length > 1 || mapboxViewportIdx < 0;\n\n if (hasNonMapboxLayers || hasNonMapboxViews) {\n if (mapboxViewportIdx >= 0) {\n viewports = viewports.slice();\n viewports[mapboxViewportIdx] = getViewport(deck, map, false);\n }\n\n deck._drawLayers('mapbox-repaint', {\n viewports,\n layerFilter: params =>\n (!deck.props.layerFilter || deck.props.layerFilter(params)) &&\n (params.viewport.id !== 'mapbox' || !mapboxLayerIds.includes(params.layer.id)),\n clearCanvas: false\n });\n }\n }\n\n // End of render cycle, clear generated viewport\n (deck.userData as UserData).currentViewport = null;\n}\n\nfunction onMapMove(deck: Deck, map: Map): void {\n deck.setProps({\n viewState: getViewState(map)\n });\n // Camera changed, will trigger a map repaint right after this\n // Clear any change flag triggered by setting viewState so that deck does not request\n // a second repaint\n deck.needsRedraw({clearRedrawFlags: true});\n}\n\nfunction updateLayers(deck: Deck): void {\n if ((deck.userData as UserData).isExternal) {\n return;\n }\n\n const layers: Layer[] = [];\n let layerIndex = 0;\n (deck.userData as UserData).mapboxLayers.forEach(deckLayer => {\n const LayerType = deckLayer.props.type;\n const layer = new LayerType(deckLayer.props, {_offset: layerIndex++});\n layers.push(layer);\n });\n deck.setProps({layers});\n}\n"],"file":"deck-utils.js"}
@@ -11,11 +11,19 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
11
11
 
12
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
13
 
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
14
16
  var _deckUtils = require("./deck-utils");
15
17
 
16
18
  var MapboxLayer = function () {
17
19
  function MapboxLayer(props) {
18
20
  (0, _classCallCheck2.default)(this, MapboxLayer);
21
+ (0, _defineProperty2.default)(this, "id", void 0);
22
+ (0, _defineProperty2.default)(this, "type", void 0);
23
+ (0, _defineProperty2.default)(this, "renderingMode", void 0);
24
+ (0, _defineProperty2.default)(this, "map", void 0);
25
+ (0, _defineProperty2.default)(this, "deck", void 0);
26
+ (0, _defineProperty2.default)(this, "props", void 0);
19
27
 
20
28
  if (!props.id) {
21
29
  throw new Error('Layer must have an unique id');
@@ -43,7 +51,9 @@ var MapboxLayer = function () {
43
51
  }, {
44
52
  key: "onRemove",
45
53
  value: function onRemove() {
46
- (0, _deckUtils.removeLayer)(this.deck, this);
54
+ if (this.deck) {
55
+ (0, _deckUtils.removeLayer)(this.deck, this);
56
+ }
47
57
  }
48
58
  }, {
49
59
  key: "setProps",
@@ -58,7 +68,7 @@ var MapboxLayer = function () {
58
68
  }
59
69
  }, {
60
70
  key: "render",
61
- value: function render(gl, matrix) {
71
+ value: function render() {
62
72
  (0, _deckUtils.drawLayer)(this.deck, this.map, this);
63
73
  }
64
74
  }]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mapbox-layer.js"],"names":["MapboxLayer","props","id","Error","type","renderingMode","map","deck","gl","Object","assign","matrix"],"mappings":";;;;;;;;;;;;;AAAA;;IAEqBA,W;AAEnB,uBAAYC,KAAZ,EAAmB;AAAA;;AACjB,QAAI,CAACA,KAAK,CAACC,EAAX,EAAe;AACb,YAAM,IAAIC,KAAJ,CAAU,8BAAV,CAAN;AACD;;AAED,SAAKD,EAAL,GAAUD,KAAK,CAACC,EAAhB;AACA,SAAKE,IAAL,GAAY,QAAZ;AACA,SAAKC,aAAL,GAAqBJ,KAAK,CAACI,aAAN,IAAuB,IAA5C;AACA,SAAKC,GAAL,GAAW,IAAX;AACA,SAAKC,IAAL,GAAY,IAAZ;AACA,SAAKN,KAAL,GAAaA,KAAb;AACD;;;;WAID,eAAMK,GAAN,EAAWE,EAAX,EAAe;AACb,WAAKF,GAAL,GAAWA,GAAX;AACA,WAAKC,IAAL,GAAY,gCAAgB;AAACD,QAAAA,GAAG,EAAHA,GAAD;AAAME,QAAAA,EAAE,EAAFA,EAAN;AAAUD,QAAAA,IAAI,EAAE,KAAKN,KAAL,CAAWM;AAA3B,OAAhB,CAAZ;AACA,+BAAS,KAAKA,IAAd,EAAoB,IAApB;AACD;;;WAED,oBAAW;AACT,kCAAY,KAAKA,IAAjB,EAAuB,IAAvB;AACD;;;WAED,kBAASN,KAAT,EAAgB;AAEdQ,MAAAA,MAAM,CAACC,MAAP,CAAc,KAAKT,KAAnB,EAA0BA,KAA1B,EAAiC;AAACC,QAAAA,EAAE,EAAE,KAAKA;AAAV,OAAjC;;AAEA,UAAI,KAAKK,IAAT,EAAe;AACb,oCAAY,KAAKA,IAAjB,EAAuB,IAAvB;AACD;AACF;;;WAED,gBAAOC,EAAP,EAAWG,MAAX,EAAmB;AACjB,gCAAU,KAAKJ,IAAf,EAAqB,KAAKD,GAA1B,EAA+B,IAA/B;AACD","sourcesContent":["import {getDeckInstance, addLayer, removeLayer, updateLayer, drawLayer} from './deck-utils';\n\nexport default class MapboxLayer {\n /* eslint-disable no-this-before-super */\n constructor(props) {\n if (!props.id) {\n throw new Error('Layer must have an unique id');\n }\n\n this.id = props.id;\n this.type = 'custom';\n this.renderingMode = props.renderingMode || '3d';\n this.map = null;\n this.deck = null;\n this.props = props;\n }\n\n /* Mapbox custom layer methods */\n\n onAdd(map, gl) {\n this.map = map;\n this.deck = getDeckInstance({map, gl, deck: this.props.deck});\n addLayer(this.deck, this);\n }\n\n onRemove() {\n removeLayer(this.deck, this);\n }\n\n setProps(props) {\n // id cannot be changed\n Object.assign(this.props, props, {id: this.id});\n // safe guard in case setProps is called before onAdd\n if (this.deck) {\n updateLayer(this.deck, this);\n }\n }\n\n render(gl, matrix) {\n drawLayer(this.deck, this.map, this);\n }\n}\n"],"file":"mapbox-layer.js"}
1
+ {"version":3,"sources":["../../src/mapbox-layer.ts"],"names":["MapboxLayer","props","id","Error","type","renderingMode","map","deck","gl","Object","assign"],"mappings":";;;;;;;;;;;;;;;AAAA;;IAUqBA,W;AASnB,uBAAYC,KAAZ,EAA6C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAC3C,QAAI,CAACA,KAAK,CAACC,EAAX,EAAe;AACb,YAAM,IAAIC,KAAJ,CAAU,8BAAV,CAAN;AACD;;AAED,SAAKD,EAAL,GAAUD,KAAK,CAACC,EAAhB;AACA,SAAKE,IAAL,GAAY,QAAZ;AACA,SAAKC,aAAL,GAAqBJ,KAAK,CAACI,aAAN,IAAuB,IAA5C;AACA,SAAKC,GAAL,GAAW,IAAX;AACA,SAAKC,IAAL,GAAY,IAAZ;AACA,SAAKN,KAAL,GAAaA,KAAb;AACD;;;;WAID,eAAMK,GAAN,EAAgBE,EAAhB,EAAiD;AAC/C,WAAKF,GAAL,GAAWA,GAAX;AACA,WAAKC,IAAL,GAAY,gCAAgB;AAACD,QAAAA,GAAG,EAAHA,GAAD;AAAME,QAAAA,EAAE,EAAFA,EAAN;AAAUD,QAAAA,IAAI,EAAE,KAAKN,KAAL,CAAWM;AAA3B,OAAhB,CAAZ;AACA,+BAAS,KAAKA,IAAd,EAAoB,IAApB;AACD;;;WAED,oBAAiB;AACf,UAAI,KAAKA,IAAT,EAAe;AACb,oCAAY,KAAKA,IAAjB,EAAuB,IAAvB;AACD;AACF;;;WAED,kBAASN,KAAT,EAA0C;AAExCQ,MAAAA,MAAM,CAACC,MAAP,CAAc,KAAKT,KAAnB,EAA0BA,KAA1B,EAAiC;AAACC,QAAAA,EAAE,EAAE,KAAKA;AAAV,OAAjC;;AAEA,UAAI,KAAKK,IAAT,EAAe;AACb,oCAAY,KAAKA,IAAjB,EAAuB,IAAvB;AACD;AACF;;;WAED,kBAAS;AACP,gCAAU,KAAKA,IAAf,EAAsB,KAAKD,GAA3B,EAAiC,IAAjC;AACD","sourcesContent":["import {getDeckInstance, addLayer, removeLayer, updateLayer, drawLayer} from './deck-utils';\nimport type {Map, CustomLayerInterface} from 'mapbox-gl';\nimport type {Deck, Layer} from '@deck.gl/core';\n\nexport type MapboxLayerProps<LayerT extends Layer> = Partial<LayerT['props']> & {\n id: string;\n renderingMode?: '2d' | '3d';\n deck?: Deck;\n};\n\nexport default class MapboxLayer<LayerT extends Layer> implements CustomLayerInterface {\n id: string;\n type: 'custom';\n renderingMode: '2d' | '3d';\n map: Map | null;\n deck: Deck | null;\n props: MapboxLayerProps<LayerT>;\n\n /* eslint-disable no-this-before-super */\n constructor(props: MapboxLayerProps<LayerT>) {\n if (!props.id) {\n throw new Error('Layer must have an unique id');\n }\n\n this.id = props.id;\n this.type = 'custom';\n this.renderingMode = props.renderingMode || '3d';\n this.map = null;\n this.deck = null;\n this.props = props;\n }\n\n /* Mapbox custom layer methods */\n\n onAdd(map: Map, gl: WebGLRenderingContext): void {\n this.map = map;\n this.deck = getDeckInstance({map, gl, deck: this.props.deck});\n addLayer(this.deck, this);\n }\n\n onRemove(): void {\n if (this.deck) {\n removeLayer(this.deck, this);\n }\n }\n\n setProps(props: MapboxLayerProps<LayerT>) {\n // id cannot be changed\n Object.assign(this.props, props, {id: this.id});\n // safe guard in case setProps is called before onAdd\n if (this.deck) {\n updateLayer(this.deck, this);\n }\n }\n\n render() {\n drawLayer(this.deck!, this.map!, this);\n }\n}\n"],"file":"mapbox-layer.js"}