@deck.gl/mapbox 8.7.0-alpha.1 → 8.7.0-alpha.10

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
@@ -91,32 +91,28 @@ return /******/ (function(modules) { // webpackBootstrap
91
91
  /******/
92
92
  /******/
93
93
  /******/ // Load entry module and return exports
94
- /******/ return __webpack_require__(__webpack_require__.s = "./bundle.js");
94
+ /******/ return __webpack_require__(__webpack_require__.s = "./bundle.ts");
95
95
  /******/ })
96
96
  /************************************************************************/
97
97
  /******/ ({
98
98
 
99
- /***/ "./bundle.js":
99
+ /***/ "./bundle.ts":
100
100
  /*!*******************!*\
101
- !*** ./bundle.js ***!
101
+ !*** ./bundle.ts ***!
102
102
  \*******************/
103
103
  /*! no static exports found */
104
104
  /***/ (function(module, exports, __webpack_require__) {
105
105
 
106
- const MapboxUtils = __webpack_require__(/*! ./src */ "./src/index.js");
106
+ const MapboxUtils = __webpack_require__(/*! ./src */ "./src/index.ts");
107
107
 
108
- /* global window, global */
109
- const _global = typeof window === 'undefined' ? global : window;
110
- const deck = _global.deck || {};
108
+ const deck = globalThis.deck || {}; // Check if peer dependencies are included
111
109
 
112
- // Check if peer dependencies are included
113
110
  if (!deck.Layer) {
114
111
  throw new Error('@deck.gl/core is not found');
115
112
  }
116
113
 
117
114
  module.exports = Object.assign(deck, MapboxUtils);
118
115
 
119
-
120
116
  /***/ }),
121
117
 
122
118
  /***/ "./src/deck-utils.js":
@@ -136,19 +132,22 @@ __webpack_require__.r(__webpack_exports__);
136
132
  /* harmony import */ var _deck_gl_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @deck.gl/core */ "@deck.gl/core");
137
133
  /* harmony import */ var _deck_gl_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_deck_gl_core__WEBPACK_IMPORTED_MODULE_0__);
138
134
 
139
-
140
- function getDeckInstance({map, gl, deck}) {
135
+ function getDeckInstance({
136
+ map,
137
+ gl,
138
+ deck
139
+ }) {
141
140
  // Only create one deck instance per context
142
141
  if (map.__deck) {
143
142
  return map.__deck;
144
143
  }
145
144
 
146
145
  const customRender = deck && deck.props._customRender;
147
-
148
146
  const deckProps = {
149
147
  useDevicePixels: true,
150
148
  _customRender: () => {
151
149
  map.triggerRepaint();
150
+
152
151
  if (customRender) {
153
152
  // customRender may be subscribed by DeckGL React component to update child props
154
153
  // make sure it is still called
@@ -180,60 +179,65 @@ function getDeckInstance({map, gl, deck}) {
180
179
  touchAction: 'unset',
181
180
  viewState: getViewState(map)
182
181
  });
183
- deck = new _deck_gl_core__WEBPACK_IMPORTED_MODULE_0__["Deck"](deckProps);
184
-
185
- // If deck is externally provided (React use case), we use deck's viewState to
182
+ deck = new _deck_gl_core__WEBPACK_IMPORTED_MODULE_0__["Deck"](deckProps); // If deck is externally provided (React use case), we use deck's viewState to
186
183
  // drive the map.
187
184
  // Otherwise (pure JS use case), we use the map's viewState to drive deck.
185
+
188
186
  map.on('move', () => onMapMove(deck, map));
189
187
  map.on('remove', () => {
190
188
  deck.finalize();
191
189
  map.__deck = null;
192
190
  });
193
191
  }
192
+
194
193
  deck.props.userData.mapboxVersion = getMapboxVersion(map);
195
194
  map.__deck = deck;
196
195
  map.on('render', () => {
197
196
  if (deck.layerManager) afterRender(deck, map);
198
197
  });
199
-
200
198
  return deck;
201
199
  }
202
-
203
200
  function addLayer(deck, layer) {
204
201
  deck.props.userData.mapboxLayers.add(layer);
205
202
  updateLayers(deck);
206
203
  }
207
-
208
204
  function removeLayer(deck, layer) {
209
205
  deck.props.userData.mapboxLayers.delete(layer);
210
206
  updateLayers(deck);
211
207
  }
212
-
213
208
  function updateLayer(deck, layer) {
214
209
  updateLayers(deck);
215
210
  }
216
-
217
211
  function drawLayer(deck, map, layer) {
218
- let {currentViewport} = deck.props.userData;
212
+ let {
213
+ currentViewport
214
+ } = deck.props.userData;
215
+
219
216
  if (!currentViewport) {
220
217
  // This is the first layer drawn in this render cycle.
221
218
  // Generate viewport from the current map state.
222
219
  currentViewport = getViewport(deck, map, true);
223
220
  deck.props.userData.currentViewport = currentViewport;
224
221
  }
222
+
225
223
  if (!deck.layerManager) {
226
224
  return;
227
225
  }
226
+
228
227
  deck._drawLayers('mapbox-repaint', {
229
228
  viewports: [currentViewport],
230
- layerFilter: ({layer: deckLayer}) => layer.id === deckLayer.id,
229
+ layerFilter: ({
230
+ layer: deckLayer
231
+ }) => layer.id === deckLayer.id,
231
232
  clearCanvas: false
232
233
  });
233
234
  }
234
235
 
235
236
  function getViewState(map) {
236
- const {lng, lat} = map.getCenter();
237
+ const {
238
+ lng,
239
+ lat
240
+ } = map.getCenter();
237
241
  return {
238
242
  longitude: lng,
239
243
  latitude: lat,
@@ -247,74 +251,74 @@ function getMapboxVersion(map) {
247
251
  // parse mapbox version string
248
252
  let major = 0;
249
253
  let minor = 0;
254
+
250
255
  if (map.version) {
251
- [major, minor] = map.version
252
- .split('.')
253
- .slice(0, 2)
254
- .map(Number);
256
+ [major, minor] = map.version.split('.').slice(0, 2).map(Number);
255
257
  }
256
- return {major, minor};
258
+
259
+ return {
260
+ major,
261
+ minor
262
+ };
257
263
  }
258
264
 
259
265
  function getViewport(deck, map, useMapboxProjection = true) {
260
- const {mapboxVersion} = deck.props.userData;
261
-
262
- return new _deck_gl_core__WEBPACK_IMPORTED_MODULE_0__["WebMercatorViewport"](
263
- Object.assign(
264
- {
265
- x: 0,
266
- y: 0,
267
- width: deck.width,
268
- height: deck.height,
269
- repeat: true
270
- },
271
- getViewState(map),
272
- useMapboxProjection
273
- ? {
274
- // match mapbox's projection matrix
275
- // A change of near plane was made in 1.3.0
276
- // https://github.com/mapbox/mapbox-gl-js/pull/8502
277
- nearZMultiplier:
278
- (mapboxVersion.major === 1 && mapboxVersion.minor >= 3) || mapboxVersion.major >= 2
279
- ? 0.02
280
- : 1 / (deck.height || 1)
281
- }
282
- : {
283
- // use deck.gl's own default
284
- nearZMultiplier: 0.1
285
- }
286
- )
287
- );
266
+ const {
267
+ mapboxVersion
268
+ } = deck.props.userData;
269
+ return new _deck_gl_core__WEBPACK_IMPORTED_MODULE_0__["WebMercatorViewport"](Object.assign({
270
+ x: 0,
271
+ y: 0,
272
+ width: deck.width,
273
+ height: deck.height,
274
+ repeat: true
275
+ }, getViewState(map), useMapboxProjection ? {
276
+ // match mapbox's projection matrix
277
+ // A change of near plane was made in 1.3.0
278
+ // https://github.com/mapbox/mapbox-gl-js/pull/8502
279
+ nearZMultiplier: mapboxVersion.major === 1 && mapboxVersion.minor >= 3 || mapboxVersion.major >= 2 ? 0.02 : 1 / (deck.height || 1)
280
+ } : {
281
+ // use deck.gl's own default
282
+ nearZMultiplier: 0.1
283
+ }));
288
284
  }
289
285
 
290
286
  function afterRender(deck, map) {
291
- const {mapboxLayers, isExternal} = deck.props.userData;
287
+ const {
288
+ mapboxLayers,
289
+ isExternal
290
+ } = deck.props.userData;
292
291
 
293
292
  if (isExternal) {
294
293
  // Draw non-Mapbox layers
295
294
  const mapboxLayerIds = Array.from(mapboxLayers, layer => layer.id);
296
295
  const hasNonMapboxLayers = deck.props.layers.some(layer => !mapboxLayerIds.includes(layer.id));
296
+
297
297
  if (hasNonMapboxLayers) {
298
298
  deck._drawLayers('mapbox-repaint', {
299
299
  viewports: [getViewport(deck, map, false)],
300
- layerFilter: ({layer}) => !mapboxLayerIds.includes(layer.id),
300
+ layerFilter: ({
301
+ layer
302
+ }) => !mapboxLayerIds.includes(layer.id),
301
303
  clearCanvas: false
302
304
  });
303
305
  }
304
- }
306
+ } // End of render cycle, clear generated viewport
307
+
305
308
 
306
- // End of render cycle, clear generated viewport
307
309
  deck.props.userData.currentViewport = null;
308
310
  }
309
311
 
310
312
  function onMapMove(deck, map) {
311
313
  deck.setProps({
312
314
  viewState: getViewState(map)
313
- });
314
- // Camera changed, will trigger a map repaint right after this
315
+ }); // Camera changed, will trigger a map repaint right after this
315
316
  // Clear any change flag triggered by setting viewState so that deck does not request
316
317
  // a second repaint
317
- deck.needsRedraw({clearRedrawFlags: true});
318
+
319
+ deck.needsRedraw({
320
+ clearRedrawFlags: true
321
+ });
318
322
  }
319
323
 
320
324
  function updateLayers(deck) {
@@ -328,15 +332,16 @@ function updateLayers(deck) {
328
332
  const layer = new LayerType(deckLayer.props);
329
333
  layers.push(layer);
330
334
  });
331
- deck.setProps({layers});
335
+ deck.setProps({
336
+ layers
337
+ });
332
338
  }
333
339
 
334
-
335
340
  /***/ }),
336
341
 
337
- /***/ "./src/index.js":
342
+ /***/ "./src/index.ts":
338
343
  /*!**********************!*\
339
- !*** ./src/index.js ***!
344
+ !*** ./src/index.ts ***!
340
345
  \**********************/
341
346
  /*! exports provided: MapboxLayer */
342
347
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
@@ -348,7 +353,6 @@ __webpack_require__.r(__webpack_exports__);
348
353
 
349
354
 
350
355
 
351
-
352
356
  /***/ }),
353
357
 
354
358
  /***/ "./src/mapbox-layer.js":
@@ -363,7 +367,6 @@ __webpack_require__.r(__webpack_exports__);
363
367
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return MapboxLayer; });
364
368
  /* harmony import */ var _deck_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./deck-utils */ "./src/deck-utils.js");
365
369
 
366
-
367
370
  class MapboxLayer {
368
371
  /* eslint-disable no-this-before-super */
369
372
  constructor(props) {
@@ -378,12 +381,16 @@ class MapboxLayer {
378
381
  this.deck = null;
379
382
  this.props = props;
380
383
  }
381
-
382
384
  /* Mapbox custom layer methods */
383
385
 
386
+
384
387
  onAdd(map, gl) {
385
388
  this.map = map;
386
- this.deck = Object(_deck_utils__WEBPACK_IMPORTED_MODULE_0__["getDeckInstance"])({map, gl, deck: this.props.deck});
389
+ this.deck = Object(_deck_utils__WEBPACK_IMPORTED_MODULE_0__["getDeckInstance"])({
390
+ map,
391
+ gl,
392
+ deck: this.props.deck
393
+ });
387
394
  Object(_deck_utils__WEBPACK_IMPORTED_MODULE_0__["addLayer"])(this.deck, this);
388
395
  }
389
396
 
@@ -393,8 +400,10 @@ class MapboxLayer {
393
400
 
394
401
  setProps(props) {
395
402
  // id cannot be changed
396
- Object.assign(this.props, props, {id: this.id});
397
- // safe guard in case setProps is called before onAdd
403
+ Object.assign(this.props, props, {
404
+ id: this.id
405
+ }); // safe guard in case setProps is called before onAdd
406
+
398
407
  if (this.deck) {
399
408
  Object(_deck_utils__WEBPACK_IMPORTED_MODULE_0__["updateLayer"])(this.deck, this);
400
409
  }
@@ -403,8 +412,8 @@ class MapboxLayer {
403
412
  render(gl, matrix) {
404
413
  Object(_deck_utils__WEBPACK_IMPORTED_MODULE_0__["drawLayer"])(this.deck, this.map, this);
405
414
  }
406
- }
407
415
 
416
+ }
408
417
 
409
418
  /***/ }),
410
419
 
@@ -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","blendFunc","blendEquation","userData","isExternal","mapboxLayers","Set","setProps","Object","assign","width","height","touchAction","viewState","getViewState","Deck","on","onMapMove","finalize","mapboxVersion","getMapboxVersion","layerManager","afterRender","addLayer","layer","add","updateLayers","removeLayer","delete","updateLayer","drawLayer","currentViewport","getViewport","_drawLayers","viewports","layerFilter","deckLayer","id","clearCanvas","getCenter","lng","lat","longitude","latitude","zoom","getZoom","bearing","getBearing","pitch","getPitch","major","minor","version","split","slice","Number","useMapboxProjection","WebMercatorViewport","x","y","repeat","nearZMultiplier","mapboxLayerIds","Array","from","hasNonMapboxLayers","layers","some","includes","needsRedraw","clearRedrawFlags","forEach","LayerType","type","push"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAEO,SAASA,eAAT,OAA0C;AAAA,MAAhBC,GAAgB,QAAhBA,GAAgB;AAAA,MAAXC,EAAW,QAAXA,EAAW;AAAA,MAAPC,IAAO,QAAPA,IAAO;;AAE/C,MA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,EAAAA,IAAI,CAACiB,QAAL,CAAc;AAAC2D,IAAAA,MAAM,EAANA;AAAD,GAAd;AACD","sourcesContent":["import {Deck, WebMercatorViewport} 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 blendFunc: [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA],\n blendEquation: gl.FUNC_ADD\n },\n userData: {\n isExternal: false,\n mapboxLayers: new Set()\n }\n };\n\n if (deck) {\n deck.setProps(deckProps);\n deck.props.userData.isExternal = true;\n } else {\n // Using external gl context - do not set css size\n Object.assign(deckProps, {\n gl,\n width: false,\n height: false,\n touchAction: 'unset',\n viewState: getViewState(map)\n });\n deck = new Deck(deckProps);\n\n // If deck is externally provided (React use case), we use deck's viewState to\n // 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 map.on('remove', () => {\n deck.finalize();\n map.__deck = null;\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 deck._drawLayers('mapbox-repaint', {\n viewports: [currentViewport],\n layerFilter: ({layer: deckLayer}) => layer.id === deckLayer.id,\n clearCanvas: false\n });\n}\n\nfunction getViewState(map) {\n const {lng, lat} = map.getCenter();\n return {\n longitude: lng,\n latitude: lat,\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch()\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\n .split('.')\n .slice(0, 2)\n .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 x: 0,\n y: 0,\n width: deck.width,\n height: deck.height,\n repeat: true\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 if (hasNonMapboxLayers) {\n deck._drawLayers('mapbox-repaint', {\n viewports: [getViewport(deck, map, false)],\n layerFilter: ({layer}) => !mapboxLayerIds.includes(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 deck.props.userData.mapboxLayers.forEach(deckLayer => {\n const LayerType = deckLayer.props.type;\n const layer = new LayerType(deckLayer.props);\n layers.push(layer);\n });\n deck.setProps({layers});\n}\n"],"file":"deck-utils.js"}
1
+ {"version":3,"sources":["../../src/deck-utils.js"],"names":["getDeckInstance","map","gl","deck","__deck","customRender","props","_customRender","deckProps","useDevicePixels","triggerRepaint","parameters","depthMask","depthTest","blendFunc","blendEquation","userData","isExternal","mapboxLayers","Set","setProps","Object","assign","width","height","touchAction","viewState","getViewState","Deck","on","onMapMove","finalize","mapboxVersion","getMapboxVersion","layerManager","afterRender","addLayer","layer","add","updateLayers","removeLayer","delete","updateLayer","drawLayer","currentViewport","getViewport","_drawLayers","viewports","layerFilter","deckLayer","id","clearCanvas","getCenter","lng","lat","longitude","latitude","zoom","getZoom","bearing","getBearing","pitch","getPitch","major","minor","version","split","slice","Number","useMapboxProjection","WebMercatorViewport","x","y","repeat","nearZMultiplier","mapboxLayerIds","Array","from","hasNonMapboxLayers","layers","some","includes","needsRedraw","clearRedrawFlags","forEach","LayerType","type","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;AAEhB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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 blendFunc: [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA],\n blendEquation: gl.FUNC_ADD\n },\n userData: {\n isExternal: false,\n mapboxLayers: new Set()\n }\n };\n\n if (deck) {\n deck.setProps(deckProps);\n deck.props.userData.isExternal = true;\n } else {\n // Using external gl context - do not set css size\n Object.assign(deckProps, {\n gl,\n width: false,\n height: false,\n touchAction: 'unset',\n viewState: getViewState(map)\n });\n deck = new Deck(deckProps);\n\n // If deck is externally provided (React use case), we use deck's viewState to\n // 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 map.on('remove', () => {\n deck.finalize();\n map.__deck = null;\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 deck._drawLayers('mapbox-repaint', {\n viewports: [currentViewport],\n layerFilter: ({layer: deckLayer}) => layer.id === deckLayer.id,\n clearCanvas: false\n });\n}\n\nfunction getViewState(map) {\n const {lng, lat} = map.getCenter();\n return {\n longitude: lng,\n latitude: lat,\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch()\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 x: 0,\n y: 0,\n width: deck.width,\n height: deck.height,\n repeat: true\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 if (hasNonMapboxLayers) {\n deck._drawLayers('mapbox-repaint', {\n viewports: [getViewport(deck, map, false)],\n layerFilter: ({layer}) => !mapboxLayerIds.includes(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 deck.props.userData.mapboxLayers.forEach(deckLayer => {\n const LayerType = deckLayer.props.type;\n const layer = new LayerType(deckLayer.props);\n layers.push(layer);\n });\n deck.setProps({layers});\n}\n"],"file":"deck-utils.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export {default as MapboxLayer} from './mapbox-layer';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export {default as MapboxLayer} from './mapbox-layer';\n"],"file":"index.js"}
@@ -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;;;;0BAIKK,G,EAAKE,E,EAAI;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;;;+BAEU;AACT,kCAAY,KAAKA,IAAjB,EAAuB,IAAvB;AACD;;;6BAEQN,K,EAAO;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;;;2BAEMC,E,EAAIG,M,EAAQ;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.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 +1 @@
1
- {"version":3,"sources":["../../src/deck-utils.js"],"names":["Deck","WebMercatorViewport","getDeckInstance","map","gl","deck","__deck","customRender","props","_customRender","deckProps","useDevicePixels","triggerRepaint","parameters","depthMask","depthTest","blendFunc","blendEquation","userData","isExternal","mapboxLayers","Set","setProps","Object","assign","width","height","touchAction","viewState","getViewState","on","onMapMove","finalize","mapboxVersion","getMapboxVersion","layerManager","afterRender","addLayer","layer","add","updateLayers","removeLayer","delete","updateLayer","drawLayer","currentViewport","getViewport","_drawLayers","viewports","layerFilter","deckLayer","id","clearCanvas","lng","lat","getCenter","longitude","latitude","zoom","getZoom","bearing","getBearing","pitch","getPitch","major","minor","version","split","slice","Number","useMapboxProjection","x","y","repeat","nearZMultiplier","mapboxLayerIds","Array","from","hasNonMapboxLayers","layers","some","includes","needsRedraw","clearRedrawFlags","forEach","LayerType","type","push"],"mappings":"AAAA,SAAQA,IAAR,EAAcC,mBAAd,QAAwC,eAAxC;AAEA,OAAO,SAASC,eAAT,CAAyB;AAACC,EAAAA,GAAD;AAAMC,EAAAA,EAAN;AAAUC,EAAAA;AAAV,CAAzB,EAA0C;AAE/C,MAAIF,GAAG,CAACG,MAAR,EAAgB;AACd,WAAOH,GAAG,CAACG,MAAX;AACD;;AAED,QAAMC,YAAY,GAAGF,IAAI,IAAIA,IAAI,CAACG,KAAL,CAAWC,aAAxC;AAEA,QAAMC,SAAS,GAAG;AAChBC,IAAAA,eAAe,EAAE,IADD;AAEhBF,IAAAA,aAAa,EAAE,MAAM;AACnBN,MAAAA,GAAG,CAACS,cAAJ;;AACA,UAAIL,YAAJ,EAAkB;AAGhBA,QAAAA,YAAY;AACb;AACF,KATe;AAWhBM,IAAAA,UAAU,E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;AAED,SAASd,SAAT,CAAmB1B,IAAnB,EAAyBF,GAAzB,EAA8B;AAC5BE,EAAAA,IAAI,CAACiB,QAAL,CAAc;AACZM,IAAAA,SAAS,EAAEC,YAAY,CAAC1B,GAAD;AADX,GAAd;AAMAE,EAAAA,IAAI,CAAC6E,WAAL,CAAiB;AAACC,IAAAA,gBAAgB,EAAE;AAAnB,GAAjB;AACD;;AAED,SAAS3C,YAAT,CAAsBnC,IAAtB,EAA4B;AAC1B,MAAIA,IAAI,CAACG,KAAL,CAAWU,QAAX,CAAoBC,UAAxB,EAAoC;AAClC;AACD;;AAED,QAAM4D,MAAM,GAAG,EAAf;AACA1E,EAAAA,IAAI,CAACG,KAAL,CAAWU,QAAX,CAAoBE,YAApB,CAAiCgE,OAAjC,CAAyClC,SAAS,IAAI;AACpD,UAAMmC,SAAS,GAAGnC,SAAS,CAAC1C,KAAV,CAAgB8E,IAAlC;AACA,UAAMhD,KAAK,GAAG,IAAI+C,SAAJ,CAAcnC,SAAS,CAAC1C,KAAxB,CAAd;AACAuE,IAAAA,MAAM,CAACQ,IAAP,CAAYjD,KAAZ;AACD,GAJD;AAKAjC,EAAAA,IAAI,CAACiB,QAAL,CAAc;AAACyD,IAAAA;AAAD,GAAd;AACD","sourcesContent":["import {Deck, WebMercatorViewport} 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 blendFunc: [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA],\n blendEquation: gl.FUNC_ADD\n },\n userData: {\n isExternal: false,\n mapboxLayers: new Set()\n }\n };\n\n if (deck) {\n deck.setProps(deckProps);\n deck.props.userData.isExternal = true;\n } else {\n // Using external gl context - do not set css size\n Object.assign(deckProps, {\n gl,\n width: false,\n height: false,\n touchAction: 'unset',\n viewState: getViewState(map)\n });\n deck = new Deck(deckProps);\n\n // If deck is externally provided (React use case), we use deck's viewState to\n // 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 map.on('remove', () => {\n deck.finalize();\n map.__deck = null;\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 deck._drawLayers('mapbox-repaint', {\n viewports: [currentViewport],\n layerFilter: ({layer: deckLayer}) => layer.id === deckLayer.id,\n clearCanvas: false\n });\n}\n\nfunction getViewState(map) {\n const {lng, lat} = map.getCenter();\n return {\n longitude: lng,\n latitude: lat,\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch()\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\n .split('.')\n .slice(0, 2)\n .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 x: 0,\n y: 0,\n width: deck.width,\n height: deck.height,\n repeat: true\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 if (hasNonMapboxLayers) {\n deck._drawLayers('mapbox-repaint', {\n viewports: [getViewport(deck, map, false)],\n layerFilter: ({layer}) => !mapboxLayerIds.includes(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 deck.props.userData.mapboxLayers.forEach(deckLayer => {\n const LayerType = deckLayer.props.type;\n const layer = new LayerType(deckLayer.props);\n layers.push(layer);\n });\n deck.setProps({layers});\n}\n"],"file":"deck-utils.js"}
1
+ {"version":3,"sources":["../../src/deck-utils.js"],"names":["Deck","WebMercatorViewport","getDeckInstance","map","gl","deck","__deck","customRender","props","_customRender","deckProps","useDevicePixels","triggerRepaint","parameters","depthMask","depthTest","blendFunc","blendEquation","userData","isExternal","mapboxLayers","Set","setProps","Object","assign","width","height","touchAction","viewState","getViewState","on","onMapMove","finalize","mapboxVersion","getMapboxVersion","layerManager","afterRender","addLayer","layer","add","updateLayers","removeLayer","delete","updateLayer","drawLayer","currentViewport","getViewport","_drawLayers","viewports","layerFilter","deckLayer","id","clearCanvas","lng","lat","getCenter","longitude","latitude","zoom","getZoom","bearing","getBearing","pitch","getPitch","major","minor","version","split","slice","Number","useMapboxProjection","x","y","repeat","nearZMultiplier","mapboxLayerIds","Array","from","hasNonMapboxLayers","layers","some","includes","needsRedraw","clearRedrawFlags","forEach","LayerType","type","push"],"mappings":"AAAA,SAAQA,IAAR,EAAcC,mBAAd,QAAwC,eAAxC;AAEA,OAAO,SAASC,eAAT,CAAyB;AAACC,EAAAA,GAAD;AAAMC,EAAAA,EAAN;AAAUC,EAAAA;AAAV,CAAzB,EAA0C;AAE/C,MAAIF,GAAG,CAACG,MAAR,EAAgB;AACd,WAAOH,GAAG,CAACG,MAAX;AACD;;AAED,QAAMC,YAAY,GAAGF,IAAI,IAAIA,IAAI,CAACG,KAAL,CAAWC,aAAxC;AAEA,QAAMC,SAAS,GAAG;AAChBC,IAAAA,eAAe,EAAE,IADD;AAEhBF,IAAAA,aAAa,EAAE,MAAM;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,SAAS,EAAE,kBAHD;AAIVC,MAAAA,aAAa;AAJH,KAXI;AAiBhBC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,UAAU,EAAE,KADJ;AAERC,MAAAA,YAAY,EAAE,IAAIC,GAAJ;AAFN;AAjBM,GAAlB;;AAuBA,MAAIhB,IAAJ,EAAU;AACRA,IAAAA,IAAI,CAACiB,QAAL,CAAcZ,SAAd;AACAL,IAAAA,IAAI,CAACG,KAAL,CAAWU,QAAX,CAAoBC,U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D;;AAED,QAAM4D,MAAM,GAAG,EAAf;AACA1E,EAAAA,IAAI,CAACG,KAAL,CAAWU,QAAX,CAAoBE,YAApB,CAAiCgE,OAAjC,CAAyClC,SAAS,IAAI;AACpD,UAAMmC,SAAS,GAAGnC,SAAS,CAAC1C,KAAV,CAAgB8E,IAAlC;AACA,UAAMhD,KAAK,GAAG,IAAI+C,SAAJ,CAAcnC,SAAS,CAAC1C,KAAxB,CAAd;AACAuE,IAAAA,MAAM,CAACQ,IAAP,CAAYjD,KAAZ;AACD,GAJD;AAKAjC,EAAAA,IAAI,CAACiB,QAAL,CAAc;AAACyD,IAAAA;AAAD,GAAd;AACD","sourcesContent":["import {Deck, WebMercatorViewport} 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 blendFunc: [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA],\n blendEquation: gl.FUNC_ADD\n },\n userData: {\n isExternal: false,\n mapboxLayers: new Set()\n }\n };\n\n if (deck) {\n deck.setProps(deckProps);\n deck.props.userData.isExternal = true;\n } else {\n // Using external gl context - do not set css size\n Object.assign(deckProps, {\n gl,\n width: false,\n height: false,\n touchAction: 'unset',\n viewState: getViewState(map)\n });\n deck = new Deck(deckProps);\n\n // If deck is externally provided (React use case), we use deck's viewState to\n // 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 map.on('remove', () => {\n deck.finalize();\n map.__deck = null;\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 deck._drawLayers('mapbox-repaint', {\n viewports: [currentViewport],\n layerFilter: ({layer: deckLayer}) => layer.id === deckLayer.id,\n clearCanvas: false\n });\n}\n\nfunction getViewState(map) {\n const {lng, lat} = map.getCenter();\n return {\n longitude: lng,\n latitude: lat,\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch()\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 x: 0,\n y: 0,\n width: deck.width,\n height: deck.height,\n repeat: true\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 if (hasNonMapboxLayers) {\n deck._drawLayers('mapbox-repaint', {\n viewports: [getViewport(deck, map, false)],\n layerFilter: ({layer}) => !mapboxLayerIds.includes(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 deck.props.userData.mapboxLayers.forEach(deckLayer => {\n const LayerType = deckLayer.props.type;\n const layer = new LayerType(deckLayer.props);\n layers.push(layer);\n });\n deck.setProps({layers});\n}\n"],"file":"deck-utils.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.js"],"names":["default","MapboxLayer"],"mappings":"AAAA,SAAQA,OAAO,IAAIC,WAAnB,QAAqC,gBAArC","sourcesContent":["export {default as MapboxLayer} from './mapbox-layer';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":["default","MapboxLayer"],"mappings":"AAAA,SAAQA,OAAO,IAAIC,WAAnB,QAAqC,gBAArC","sourcesContent":["export {default as MapboxLayer} from './mapbox-layer';\n"],"file":"index.js"}
package/dist.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("deck")):"function"==typeof define&&define.amd?define(["deck"],r):"object"==typeof exports?exports.deck=r(require("deck")):e.deck=r(e.deck)}(window,(function(e){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=4)}([function(r,t){r.exports=e},function(e,r){e.exports=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}},function(e,r){function t(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}},function(e,r,t){var n=t(5),o=t(6),i=t(7);e.exports=function(e,r){return n(e)||o(e,r)||i()}},function(e,r,t){var n=t(8),o=("undefined"==typeof window?global:window).deck||{};if(!o.Layer)throw new Error("@deck.gl/core is not found");e.exports=Object.assign(o,n)},function(e,r){e.exports=function(e){if(Array.isArray(e))return e}},function(e,r){e.exports=function(e,r){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var t=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(t.push(a.value),!r||t.length!==r);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return t}}},function(e,r){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,r,t){"use strict";t.r(r);var n=t(1),o=t.n(n),i=t(2),a=t.n(i),u=t(3),s=t.n(u),c=t(0);function p(e){var r=e.map,t=e.gl,n=e.deck;if(r.__deck)return r.__deck;var o=n&&n.props._customRender,i={useDevicePixels:!0,_customRender:function(){r.triggerRepaint(),o&&o()},parameters:{depthMask:!0,depthTest:!0,blendFunc:[770,771,1,771],blendEquation:32774},userData:{isExternal:!1,mapboxLayers:new Set}};return n?(n.setProps(i),n.props.userData.isExternal=!0):(Object.assign(i,{gl:t,width:!1,height:!1,touchAction:"unset",viewState:l(r)}),n=new c.Deck(i),r.on("move",(function(){return function(e,r){e.setProps({viewState:l(r)}),e.needsRedraw({clearRedrawFlags:!0})}(n,r)})),r.on("remove",(function(){n.finalize(),r.__deck=null}))),n.props.userData.mapboxVersion=function(e){var r=0,t=0;if(e.version){var n=e.version.split(".").slice(0,2).map(Number),o=s()(n,2);r=o[0],t=o[1]}return{major:r,minor:t}}(r),r.__deck=n,r.on("render",(function(){n.layerManager&&function(e,r){var t=e.props.userData,n=t.mapboxLayers;if(t.isExternal){var o=Array.from(n,(function(e){return e.id}));e.props.layers.some((function(e){return!o.includes(e.id)}))&&e._drawLayers("mapbox-repaint",{viewports:[d(e,r,!1)],layerFilter:function(e){var r=e.layer;return!o.includes(r.id)},clearCanvas:!1})}e.props.userData.currentViewport=null}(n,r)})),n}function l(e){var r=e.getCenter();return{longitude:r.lng,latitude:r.lat,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch()}}function d(e,r){var t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=e.props.userData.mapboxVersion;return new c.WebMercatorViewport(Object.assign({x:0,y:0,width:e.width,height:e.height,repeat:!0},l(r),t?{nearZMultiplier:1===n.major&&n.minor>=3||n.major>=2?.02:1/(e.height||1)}:{nearZMultiplier:.1}))}function f(e){if(!e.props.userData.isExternal){var r=[];e.props.userData.mapboxLayers.forEach((function(e){var t=new(0,e.props.type)(e.props);r.push(t)})),e.setProps({layers:r})}}var y=function(){function e(r){if(o()(this,e),!r.id)throw new Error("Layer must have an unique id");this.id=r.id,this.type="custom",this.renderingMode=r.renderingMode||"3d",this.map=null,this.deck=null,this.props=r}return a()(e,[{key:"onAdd",value:function(e,r){var t,n;this.map=e,this.deck=p({map:e,gl:r,deck:this.props.deck}),t=this.deck,n=this,t.props.userData.mapboxLayers.add(n),f(t)}},{key:"onRemove",value:function(){var e,r;e=this.deck,r=this,e.props.userData.mapboxLayers.delete(r),f(e)}},{key:"setProps",value:function(e){Object.assign(this.props,e,{id:this.id}),this.deck&&f(this.deck)}},{key:"render",value:function(e,r){var t,n,o,i;t=this.deck,n=this.map,o=this,(i=t.props.userData.currentViewport)||(i=d(t,n,!0),t.props.userData.currentViewport=i),t.layerManager&&t._drawLayers("mapbox-repaint",{viewports:[i],layerFilter:function(e){var r=e.layer;return o.id===r.id},clearCanvas:!1})}}]),e}();t.d(r,"MapboxLayer",(function(){return y}))}])}));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("deck")):"function"==typeof define&&define.amd?define(["deck"],r):"object"==typeof exports?exports.deck=r(require("deck")):e.deck=r(e.deck)}(window,(function(e){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=4)}([function(r,t){r.exports=e},function(e,r){e.exports=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}},function(e,r){function t(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}},function(e,r,t){var n=t(5),o=t(6),i=t(7);e.exports=function(e,r){return n(e)||o(e,r)||i()}},function(e,r,t){var n=t(8),o=globalThis.deck||{};if(!o.Layer)throw new Error("@deck.gl/core is not found");e.exports=Object.assign(o,n)},function(e,r){e.exports=function(e){if(Array.isArray(e))return e}},function(e,r){e.exports=function(e,r){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var t=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(t.push(a.value),!r||t.length!==r);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return t}}},function(e,r){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,r,t){"use strict";t.r(r);var n=t(1),o=t.n(n),i=t(2),a=t.n(i),u=t(3),s=t.n(u),c=t(0);function p(e){var r=e.map,t=e.gl,n=e.deck;if(r.__deck)return r.__deck;var o=n&&n.props._customRender,i={useDevicePixels:!0,_customRender:function(){r.triggerRepaint(),o&&o()},parameters:{depthMask:!0,depthTest:!0,blendFunc:[770,771,1,771],blendEquation:32774},userData:{isExternal:!1,mapboxLayers:new Set}};return n?(n.setProps(i),n.props.userData.isExternal=!0):(Object.assign(i,{gl:t,width:!1,height:!1,touchAction:"unset",viewState:l(r)}),n=new c.Deck(i),r.on("move",(function(){return function(e,r){e.setProps({viewState:l(r)}),e.needsRedraw({clearRedrawFlags:!0})}(n,r)})),r.on("remove",(function(){n.finalize(),r.__deck=null}))),n.props.userData.mapboxVersion=function(e){var r=0,t=0;if(e.version){var n=e.version.split(".").slice(0,2).map(Number),o=s()(n,2);r=o[0],t=o[1]}return{major:r,minor:t}}(r),r.__deck=n,r.on("render",(function(){n.layerManager&&function(e,r){var t=e.props.userData,n=t.mapboxLayers;if(t.isExternal){var o=Array.from(n,(function(e){return e.id}));e.props.layers.some((function(e){return!o.includes(e.id)}))&&e._drawLayers("mapbox-repaint",{viewports:[f(e,r,!1)],layerFilter:function(e){var r=e.layer;return!o.includes(r.id)},clearCanvas:!1})}e.props.userData.currentViewport=null}(n,r)})),n}function l(e){var r=e.getCenter();return{longitude:r.lng,latitude:r.lat,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch()}}function f(e,r){var t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=e.props.userData.mapboxVersion;return new c.WebMercatorViewport(Object.assign({x:0,y:0,width:e.width,height:e.height,repeat:!0},l(r),t?{nearZMultiplier:1===n.major&&n.minor>=3||n.major>=2?.02:1/(e.height||1)}:{nearZMultiplier:.1}))}function d(e){if(!e.props.userData.isExternal){var r=[];e.props.userData.mapboxLayers.forEach((function(e){var t=new(0,e.props.type)(e.props);r.push(t)})),e.setProps({layers:r})}}var y=function(){function e(r){if(o()(this,e),!r.id)throw new Error("Layer must have an unique id");this.id=r.id,this.type="custom",this.renderingMode=r.renderingMode||"3d",this.map=null,this.deck=null,this.props=r}return a()(e,[{key:"onAdd",value:function(e,r){var t,n;this.map=e,this.deck=p({map:e,gl:r,deck:this.props.deck}),t=this.deck,n=this,t.props.userData.mapboxLayers.add(n),d(t)}},{key:"onRemove",value:function(){var e,r;e=this.deck,r=this,e.props.userData.mapboxLayers.delete(r),d(e)}},{key:"setProps",value:function(e){Object.assign(this.props,e,{id:this.id}),this.deck&&d(this.deck)}},{key:"render",value:function(e,r){var t,n,o,i;t=this.deck,n=this.map,o=this,(i=t.props.userData.currentViewport)||(i=f(t,n,!0),t.props.userData.currentViewport=i),t.layerManager&&t._drawLayers("mapbox-repaint",{viewports:[i],layerFilter:function(e){var r=e.layer;return o.id===r.id},clearCanvas:!1})}}]),e}();t.d(r,"MapboxLayer",(function(){return y}))}])}));
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@deck.gl/mapbox",
3
3
  "description": "Use deck.gl layers as custom mapbox-gl-js layers",
4
4
  "license": "MIT",
5
- "version": "8.7.0-alpha.1",
5
+ "version": "8.7.0-alpha.10",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -31,5 +31,5 @@
31
31
  "peerDependencies": {
32
32
  "@deck.gl/core": "^8.0.0"
33
33
  },
34
- "gitHead": "dbaa3941a41f3ddceecad4d2d2879515d97d2510"
34
+ "gitHead": "b6c48fb68b66755743c28776a0642b56a2df086a"
35
35
  }
package/src/deck-utils.js CHANGED
@@ -111,10 +111,7 @@ function getMapboxVersion(map) {
111
111
  let major = 0;
112
112
  let minor = 0;
113
113
  if (map.version) {
114
- [major, minor] = map.version
115
- .split('.')
116
- .slice(0, 2)
117
- .map(Number);
114
+ [major, minor] = map.version.split('.').slice(0, 2).map(Number);
118
115
  }
119
116
  return {major, minor};
120
117
  }
File without changes