@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.
@@ -49,7 +49,7 @@ var MapboxOverlay = function () {
49
49
  deck.setProps({
50
50
  viewState: (0, _deckUtils.getViewState)(_this._map)
51
51
  });
52
- deck.redraw(false);
52
+ deck.redraw();
53
53
  }
54
54
  });
55
55
  (0, _defineProperty2.default)(this, "_handleMouseEvent", function (event) {
@@ -67,11 +67,10 @@ var MapboxOverlay = function () {
67
67
 
68
68
  switch (event.type) {
69
69
  case 'click':
70
- deck._lastPointerDownInfo = deck.pickObject(_objectSpread(_objectSpread({}, mockEvent.offsetCenter), {}, {
71
- radius: deck.props.pickingRadius
72
- }));
73
70
  mockEvent.tapCount = 1;
74
71
 
72
+ deck._onPointerDown(mockEvent);
73
+
75
74
  deck._onEvent(mockEvent);
76
75
 
77
76
  break;
@@ -162,6 +161,7 @@ var MapboxOverlay = function () {
162
161
  }
163
162
 
164
163
  (_this$_deck = this._deck) === null || _this$_deck === void 0 ? void 0 : _this$_deck.finalize();
164
+ this._deck = undefined;
165
165
  this._map = undefined;
166
166
  this._container = undefined;
167
167
  }
@@ -173,17 +173,20 @@ var MapboxOverlay = function () {
173
173
  }, {
174
174
  key: "pickObject",
175
175
  value: function pickObject(params) {
176
- return this._deck && this._deck.pickObject(params);
176
+ (0, _core.assert)(this._deck);
177
+ return this._deck.pickObject(params);
177
178
  }
178
179
  }, {
179
180
  key: "pickMultipleObjects",
180
181
  value: function pickMultipleObjects(params) {
181
- return this._deck && this._deck.pickMultipleObjects(params);
182
+ (0, _core.assert)(this._deck);
183
+ return this._deck.pickMultipleObjects(params);
182
184
  }
183
185
  }, {
184
186
  key: "pickObjects",
185
187
  value: function pickObjects(params) {
186
- return this._deck && this._deck.pickObjects(params);
188
+ (0, _core.assert)(this._deck);
189
+ return this._deck.pickObjects(params);
187
190
  }
188
191
  }, {
189
192
  key: "finalize",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mapbox-overlay.ts"],"names":["MapboxOverlay","props","_map","_container","getContainer","clientWidth","clientHeight","Object","assign","style","width","height","deck","_deck","setProps","viewState","redraw","event","mockEvent","type","offsetCenter","point","srcEvent","_lastPointerDownInfo","pickObject","radius","pickingRadius","tapCount","_onEvent","_onPointerMove","_props","map","container","document","createElement","position","left","top","pointerEvents","Deck","parent","on","_updateContainerSize","_updateViewState","_handleMouseEvent","off","finalize","undefined","params","pickMultipleObjects","pickObjects","removeControl"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;;;;;IAQqBA,a;AAMnB,yBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gEA4FI,YAAM;AAC3B,UAAI,KAAI,CAACC,IAAL,IAAa,KAAI,CAACC,UAAtB,EAAkC;AAChC,oCAAoC,KAAI,CAACD,IAAL,CAAUE,YAAV,EAApC;AAAA,YAAOC,WAAP,yBAAOA,WAAP;AAAA,YAAoBC,YAApB,yBAAoBA,YAApB;;AACAC,QAAAA,MAAM,CAACC,MAAP,CAAc,KAAI,CAACL,UAAL,CAAgBM,KAA9B,EAAqC;AACnCC,UAAAA,KAAK,YAAKL,WAAL,OAD8B;AAEnCM,UAAAA,MAAM,YAAKL,YAAL;AAF6B,SAArC;AAID;AACF,KApGkB;AAAA,4DAsGA,YAAM;AACvB,UAAMM,IAAI,GAAG,KAAI,CAACC,KAAlB;;AACA,UAAID,IAAJ,EAAU;AACRA,QAAAA,IAAI,CAACE,QAAL,CAAc;AAACC,UAAAA,SAAS,EAAE,6BAAa,KAAI,CAACb,IAAlB;AAAZ,SAAd;AAEAU,QAAAA,IAAI,CAACI,MAAL,CAAY,KAAZ;AACD;AACF,KA7GkB;AAAA,6DA+GC,UAACC,KAAD,EAA0B;AAC5C,UAAML,IAAI,GAAG,KAAI,CAACC,KAAlB;;AACA,UAAI,CAACD,IAAL,EAAW;AACT;AACD;;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,CAAQ,WAAR,EAAqB,KAAKD,iBAA1B;AACAb,QAAAA,GAAG,CAACc,GAAJ,CAAQ,UAAR,EAAoB,KAAKD,iBAAzB;AACAb,QAAAA,GAAG,CAACc,GAAJ,CAAQ,OAAR,EAAiB,KAAKD,iBAAtB;AACAb,QAAAA,GAAG,CAACc,GAAJ,CAAQ,UAAR,EAAoB,KAAKD,iBAAzB;AACD;;AAED,0BAAK/B,KAAL,4DAAYiC,QAAZ;AACA,WAAK5C,IAAL,GAAY6C,SAAZ;AACA,WAAK5C,UAAL,GAAkB4C,SAAlB;AACD;;;WAED,8BAAqB;AACnB,aAAO,UAAP;AACD;;;WAGD,oBAAWC,MAAX,EAAmB;AACjB,aAAO,KAAKnC,KAAL,IAAc,KAAKA,KAAL,CAAWW,UAAX,CAAsBwB,MAAtB,CAArB;AACD;;;WAGD,6BAAoBA,MAApB,EAA4B;AAC1B,aAAO,KAAKnC,KAAL,IAAc,KAAKA,KAAL,CAAWoC,mBAAX,CAA+BD,MAA/B,CAArB;AACD;;;WAGD,qBAAYA,MAAZ,EAAoB;AAClB,aAAO,KAAKnC,KAAL,IAAc,KAAKA,KAAL,CAAWqC,WAAX,CAAuBF,MAAvB,CAArB;AACD;;;WAGD,oBAAW;AACT,UAAI,KAAK9C,IAAT,EAAe;AACb,aAAKA,IAAL,CAAUiD,aAAV,CAAwB,IAAxB;AACD;AACF","sourcesContent":["import {Deck} from '@deck.gl/core';\nimport {getViewState} from './deck-utils';\n\nimport type {Map, IControl, MapMouseEvent} from 'mapbox-gl';\n\n/**\n * Implements Mapbox [IControl](https://docs.mapbox.com/mapbox-gl-js/api/markers/#icontrol) interface\n * Renders deck.gl layers over the base map and automatically synchronizes with the map's camera\n */\nexport default class MapboxOverlay implements IControl {\n private _props: any;\n private _deck: Deck;\n private _map?: Map;\n private _container?: HTMLDivElement;\n\n constructor(props) {\n this._props = {...props};\n }\n\n /** Update (partial) props of the underlying Deck instance. */\n setProps(props: any): void {\n Object.assign(this._props, props);\n\n if ('viewState' in this._props) {\n delete this._props.viewState;\n }\n\n if (this._deck) {\n this._deck.setProps(this._props);\n }\n }\n\n /** Called when the control is added to a map */\n onAdd(map: Map) {\n this._map = map;\n\n /* global document */\n const container = document.createElement('div');\n Object.assign(container.style, {\n position: 'absolute',\n left: 0,\n top: 0,\n pointerEvents: 'none'\n });\n this._container = container;\n\n this._deck = new Deck({\n ...this._props,\n parent: container,\n viewState: getViewState(map)\n });\n\n map.on('resize', this._updateContainerSize);\n map.on('render', this._updateViewState);\n map.on('mousemove', this._handleMouseEvent);\n map.on('mouseout', this._handleMouseEvent);\n map.on('click', this._handleMouseEvent);\n map.on('dblclick', this._handleMouseEvent);\n\n this._updateContainerSize();\n return container;\n }\n\n /** Called when the control is removed from a map */\n onRemove() {\n const map = this._map;\n\n if (map) {\n map.off('resize', this._updateContainerSize);\n map.off('render', this._updateViewState);\n map.off('mousemove', this._handleMouseEvent);\n map.off('mouseout', this._handleMouseEvent);\n map.off('click', this._handleMouseEvent);\n map.off('dblclick', this._handleMouseEvent);\n }\n\n this._deck?.finalize();\n this._map = undefined;\n this._container = undefined;\n }\n\n getDefaultPosition() {\n return 'top-left';\n }\n\n /** Forwards the Deck.pickObject method */\n pickObject(params) {\n return this._deck && this._deck.pickObject(params);\n }\n\n /** Forwards the Deck.pickMultipleObjects method */\n pickMultipleObjects(params) {\n return this._deck && this._deck.pickMultipleObjects(params);\n }\n\n /** Forwards the Deck.pickObjects method */\n pickObjects(params) {\n return this._deck && this._deck.pickObjects(params);\n }\n\n /** Remove from map and releases all resources */\n finalize() {\n if (this._map) {\n this._map.removeControl(this);\n }\n }\n\n _updateContainerSize = () => {\n if (this._map && this._container) {\n const {clientWidth, clientHeight} = this._map.getContainer();\n Object.assign(this._container.style, {\n width: `${clientWidth}px`,\n height: `${clientHeight}px`\n });\n }\n };\n\n _updateViewState = () => {\n const deck = this._deck;\n if (deck) {\n deck.setProps({viewState: getViewState(this._map)});\n // Redraw immediately if view state has changed\n deck.redraw(false);\n }\n };\n\n _handleMouseEvent = (event: MapMouseEvent) => {\n const deck = this._deck;\n if (!deck) {\n return;\n }\n\n const mockEvent: {\n type: string;\n offsetCenter: {x: number; y: number};\n srcEvent: MapMouseEvent;\n tapCount?: number;\n } = {\n type: event.type,\n offsetCenter: event.point,\n srcEvent: event\n };\n\n switch (event.type) {\n case 'click':\n // Hack: because we do not listen to pointer down, perform picking now\n deck._lastPointerDownInfo = deck.pickObject({\n ...mockEvent.offsetCenter,\n radius: deck.props.pickingRadius\n });\n mockEvent.tapCount = 1;\n deck._onEvent(mockEvent);\n break;\n\n case 'dblclick':\n mockEvent.type = 'click';\n mockEvent.tapCount = 2;\n deck._onEvent(mockEvent);\n break;\n\n case 'mousemove':\n mockEvent.type = 'pointermove';\n deck._onPointerMove(mockEvent);\n break;\n\n case 'mouseout':\n mockEvent.type = 'pointerleave';\n deck._onPointerMove(mockEvent);\n break;\n\n default:\n return;\n }\n };\n}\n"],"file":"mapbox-overlay.js"}
1
+ {"version":3,"sources":["../../src/mapbox-overlay.ts"],"names":["MapboxOverlay","props","_map","_container","getContainer","clientWidth","clientHeight","Object","assign","style","width","height","deck","_deck","setProps","viewState","redraw","event","mockEvent","type","offsetCenter","point","srcEvent","tapCount","_onPointerDown","_onEvent","_onPointerMove","_props","map","container","document","createElement","position","left","top","pointerEvents","Deck","parent","on","_updateContainerSize","_updateViewState","_handleMouseEvent","off","finalize","undefined","params","pickObject","pickMultipleObjects","pickObjects","removeControl"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;;;;;IAUqBA,a;AAMnB,yBAAYC,KAAZ,EAA8B;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gEAkGC,YAAM;AACnC,UAAI,KAAI,CAACC,IAAL,IAAa,KAAI,CAACC,UAAtB,EAAkC;AAChC,oCAAoC,KAAI,CAACD,IAAL,CAAUE,YAAV,EAApC;AAAA,YAAOC,WAAP,yBAAOA,WAAP;AAAA,YAAoBC,YAApB,yBA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AuBH,MAAvB,CAAP;AACD;;;WAGD,oBAAW;AACT,UAAI,KAAK3C,IAAT,EAAe;AACb,aAAKA,IAAL,CAAU+C,aAAV,CAAwB,IAAxB;AACD;AACF","sourcesContent":["import {Deck, assert} from '@deck.gl/core';\nimport {getViewState} from './deck-utils';\n\nimport type {Map, IControl, MapMouseEvent} from 'mapbox-gl';\nimport type {MjolnirGestureEvent, MjolnirPointerEvent} from 'mjolnir.js';\nimport type {DeckProps} from '@deck.gl/core';\n\n/**\n * Implements Mapbox [IControl](https://docs.mapbox.com/mapbox-gl-js/api/markers/#icontrol) interface\n * Renders deck.gl layers over the base map and automatically synchronizes with the map's camera\n */\nexport default class MapboxOverlay implements IControl {\n private _props: DeckProps;\n private _deck?: Deck;\n private _map?: Map;\n private _container?: HTMLDivElement;\n\n constructor(props: DeckProps) {\n this._props = {...props};\n }\n\n /** Update (partial) props of the underlying Deck instance. */\n setProps(props: DeckProps): void {\n Object.assign(this._props, props);\n\n if ('viewState' in this._props) {\n delete this._props.viewState;\n }\n\n if (this._deck) {\n this._deck.setProps(this._props);\n }\n }\n\n /** Called when the control is added to a map */\n onAdd(map: Map): HTMLDivElement {\n this._map = map;\n\n /* global document */\n const container = document.createElement('div');\n Object.assign(container.style, {\n position: 'absolute',\n left: 0,\n top: 0,\n pointerEvents: 'none'\n });\n this._container = container;\n\n this._deck = new Deck({\n ...this._props,\n parent: container,\n viewState: getViewState(map)\n });\n\n map.on('resize', this._updateContainerSize);\n map.on('render', this._updateViewState);\n map.on('mousemove', this._handleMouseEvent);\n map.on('mouseout', this._handleMouseEvent);\n map.on('click', this._handleMouseEvent);\n map.on('dblclick', this._handleMouseEvent);\n\n this._updateContainerSize();\n return container;\n }\n\n /** Called when the control is removed from a map */\n onRemove(): void {\n const map = this._map;\n\n if (map) {\n map.off('resize', this._updateContainerSize);\n map.off('render', this._updateViewState);\n map.off('mousemove', this._handleMouseEvent);\n map.off('mouseout', this._handleMouseEvent);\n map.off('click', this._handleMouseEvent);\n map.off('dblclick', this._handleMouseEvent);\n }\n\n this._deck?.finalize();\n this._deck = undefined;\n this._map = undefined;\n this._container = undefined;\n }\n\n getDefaultPosition() {\n return 'top-left';\n }\n\n /** Forwards the Deck.pickObject method */\n pickObject(params: Parameters<Deck['pickObject']>[0]): ReturnType<Deck['pickObject']> {\n assert(this._deck);\n return this._deck.pickObject(params);\n }\n\n /** Forwards the Deck.pickMultipleObjects method */\n pickMultipleObjects(\n params: Parameters<Deck['pickMultipleObjects']>[0]\n ): ReturnType<Deck['pickMultipleObjects']> {\n assert(this._deck);\n return this._deck.pickMultipleObjects(params);\n }\n\n /** Forwards the Deck.pickObjects method */\n pickObjects(params: Parameters<Deck['pickObjects']>[0]): ReturnType<Deck['pickObjects']> {\n assert(this._deck);\n return this._deck.pickObjects(params);\n }\n\n /** Remove from map and releases all resources */\n finalize() {\n if (this._map) {\n this._map.removeControl(this);\n }\n }\n\n private _updateContainerSize = () => {\n if (this._map && this._container) {\n const {clientWidth, clientHeight} = this._map.getContainer();\n Object.assign(this._container.style, {\n width: `${clientWidth}px`,\n height: `${clientHeight}px`\n });\n }\n };\n\n private _updateViewState = () => {\n const deck = this._deck;\n if (deck) {\n // @ts-ignore (2345) map is always defined if deck is\n deck.setProps({viewState: getViewState(this._map)});\n // Redraw immediately if view state has changed\n deck.redraw();\n }\n };\n\n private _handleMouseEvent = (event: MapMouseEvent) => {\n const deck = this._deck;\n if (!deck) {\n return;\n }\n\n const mockEvent: {\n type: string;\n offsetCenter: {x: number; y: number};\n srcEvent: MapMouseEvent;\n tapCount?: number;\n } = {\n type: event.type,\n offsetCenter: event.point,\n srcEvent: event\n };\n\n switch (event.type) {\n case 'click':\n mockEvent.tapCount = 1;\n // Hack: because we do not listen to pointer down, perform picking now\n deck._onPointerDown(mockEvent as MjolnirGestureEvent);\n deck._onEvent(mockEvent as MjolnirGestureEvent);\n break;\n\n case 'dblclick':\n mockEvent.type = 'click';\n mockEvent.tapCount = 2;\n deck._onEvent(mockEvent as MjolnirGestureEvent);\n break;\n\n case 'mousemove':\n mockEvent.type = 'pointermove';\n deck._onPointerMove(mockEvent as MjolnirPointerEvent);\n break;\n\n case 'mouseout':\n mockEvent.type = 'pointerleave';\n deck._onPointerMove(mockEvent as MjolnirPointerEvent);\n break;\n\n default:\n return;\n }\n };\n}\n"],"file":"mapbox-overlay.js"}
@@ -1,22 +1,21 @@
1
- import { Deck, WebMercatorViewport, MapView } from '@deck.gl/core';
1
+ import { Deck, WebMercatorViewport, MapView, _flatten as flatten } from '@deck.gl/core';
2
2
  export function getDeckInstance({
3
3
  map,
4
4
  gl,
5
5
  deck
6
6
  }) {
7
+ var _deck;
8
+
7
9
  if (map.__deck) {
8
10
  return map.__deck;
9
11
  }
10
12
 
11
- const customRender = deck && deck.props._customRender;
13
+ const customRender = (_deck = deck) === null || _deck === void 0 ? void 0 : _deck.props._customRender;
12
14
  const deckProps = {
13
15
  useDevicePixels: true,
14
- _customRender: () => {
16
+ _customRender: reason => {
15
17
  map.triggerRepaint();
16
-
17
- if (customRender) {
18
- customRender();
19
- }
18
+ customRender === null || customRender === void 0 ? void 0 : customRender(reason);
20
19
  },
21
20
  parameters: {
22
21
  depthMask: true,
@@ -27,10 +26,6 @@ export function getDeckInstance({
27
26
  depthFunc: 515,
28
27
  blendEquation: 32774
29
28
  },
30
- userData: {
31
- isExternal: false,
32
- mapboxLayers: new Set()
33
- },
34
29
  views: deck && deck.props.views || [new MapView({
35
30
  id: 'mapbox'
36
31
  })]
@@ -39,8 +34,8 @@ export function getDeckInstance({
39
34
  if (!deck || deck.props.gl === gl) {
40
35
  Object.assign(deckProps, {
41
36
  gl,
42
- width: false,
43
- height: false,
37
+ width: null,
38
+ height: null,
44
39
  touchAction: 'unset',
45
40
  viewState: getViewState(map)
46
41
  });
@@ -49,7 +44,7 @@ export function getDeckInstance({
49
44
 
50
45
  if (deck) {
51
46
  deck.setProps(deckProps);
52
- deck.props.userData.isExternal = true;
47
+ deck.userData.isExternal = true;
53
48
  } else {
54
49
  deck = new Deck(deckProps);
55
50
  map.on('remove', () => {
@@ -58,7 +53,8 @@ export function getDeckInstance({
58
53
  });
59
54
  }
60
55
 
61
- deck.props.userData.mapboxVersion = getMapboxVersion(map);
56
+ deck.userData.mapboxLayers = new Set();
57
+ deck.userData.mapboxVersion = getMapboxVersion(map);
62
58
  map.__deck = deck;
63
59
  map.on('render', () => {
64
60
  if (deck.layerManager) afterRender(deck, map);
@@ -66,11 +62,11 @@ export function getDeckInstance({
66
62
  return deck;
67
63
  }
68
64
  export function addLayer(deck, layer) {
69
- deck.props.userData.mapboxLayers.add(layer);
65
+ deck.userData.mapboxLayers.add(layer);
70
66
  updateLayers(deck);
71
67
  }
72
68
  export function removeLayer(deck, layer) {
73
- deck.props.userData.mapboxLayers.delete(layer);
69
+ deck.userData.mapboxLayers.delete(layer);
74
70
  updateLayers(deck);
75
71
  }
76
72
  export function updateLayer(deck, layer) {
@@ -79,11 +75,11 @@ export function updateLayer(deck, layer) {
79
75
  export function drawLayer(deck, map, layer) {
80
76
  let {
81
77
  currentViewport
82
- } = deck.props.userData;
78
+ } = deck.userData;
83
79
 
84
80
  if (!currentViewport) {
85
81
  currentViewport = getViewport(deck, map, true);
86
- deck.props.userData.currentViewport = currentViewport;
82
+ deck.userData.currentViewport = currentViewport;
87
83
  }
88
84
 
89
85
  if (!deck.layerManager) {
@@ -116,9 +112,10 @@ export function getViewState(map) {
116
112
  function getMapboxVersion(map) {
117
113
  let major = 0;
118
114
  let minor = 0;
115
+ const version = map.version;
119
116
 
120
- if (map.version) {
121
- [major, minor] = map.version.split('.').slice(0, 2).map(Number);
117
+ if (version) {
118
+ [major, minor] = version.split('.').slice(0, 2).map(Number);
122
119
  }
123
120
 
124
121
  return {
@@ -130,7 +127,7 @@ function getMapboxVersion(map) {
130
127
  function getViewport(deck, map, useMapboxProjection = true) {
131
128
  const {
132
129
  mapboxVersion
133
- } = deck.props.userData;
130
+ } = deck.userData;
134
131
  return new WebMercatorViewport(Object.assign({
135
132
  id: 'mapbox',
136
133
  x: 0,
@@ -148,11 +145,12 @@ function afterRender(deck, map) {
148
145
  const {
149
146
  mapboxLayers,
150
147
  isExternal
151
- } = deck.props.userData;
148
+ } = deck.userData;
152
149
 
153
150
  if (isExternal) {
154
151
  const mapboxLayerIds = Array.from(mapboxLayers, layer => layer.id);
155
- const hasNonMapboxLayers = deck.props.layers.some(layer => !mapboxLayerIds.includes(layer.id));
152
+ const deckLayers = flatten(deck.props.layers, Boolean);
153
+ const hasNonMapboxLayers = deckLayers.some(layer => layer && !mapboxLayerIds.includes(layer.id));
156
154
  let viewports = deck.getViewports();
157
155
  const mapboxViewportIdx = viewports.findIndex(vp => vp.id === 'mapbox');
158
156
  const hasNonMapboxViews = viewports.length > 1 || mapboxViewportIdx < 0;
@@ -171,7 +169,7 @@ function afterRender(deck, map) {
171
169
  }
172
170
  }
173
171
 
174
- deck.props.userData.currentViewport = null;
172
+ deck.userData.currentViewport = null;
175
173
  }
176
174
 
177
175
  function onMapMove(deck, map) {
@@ -184,13 +182,13 @@ function onMapMove(deck, map) {
184
182
  }
185
183
 
186
184
  function updateLayers(deck) {
187
- if (deck.props.userData.isExternal) {
185
+ if (deck.userData.isExternal) {
188
186
  return;
189
187
  }
190
188
 
191
189
  const layers = [];
192
190
  let layerIndex = 0;
193
- deck.props.userData.mapboxLayers.forEach(deckLayer => {
191
+ deck.userData.mapboxLayers.forEach(deckLayer => {
194
192
  const LayerType = deckLayer.props.type;
195
193
  const layer = new LayerType(deckLayer.props, {
196
194
  _offset: layerIndex++
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/deck-utils.js"],"names":["Deck","WebMercatorViewport","MapView","getDeckInstance","map","gl","deck","__deck","customRender","props","_customRender","deckProps","useDevicePixels","triggerRepaint","parameters","depthMask","depthTest","blend","blendFunc","polygonOffsetFill","depthFunc","blendEquation","userData","isExternal","mapboxLayers","Set","views","id","Object","assign","width","height","touchAction","viewState","getViewState","on","onMapMove","setProps","finalize","mapboxVersion","getMapboxVersion","layerManager","afterRender","addLayer","layer","add","updateLayers","removeLayer","delete","updateLayer","drawLayer","currentViewport","getViewport","_drawLayers","viewports","layerFilter","deckLayer","clearCanvas","lng","lat","getCenter","longitude","latitude","zoom","getZoom","bearing","getBearing","pitch","getPitch","repeat","getRenderWorldCopies","major","minor","version","split","slice","Number","useMapboxProjection","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,SAAQA,IAAR,EAAcC,mBAAd,EAAmCC,OAAnC,QAAiD,eAAjD;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,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,IAAI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AApB,CAAiC2E,OAAjC,CAAyC3C,SAAS,IAAI;AACpD,UAAM4C,SAAS,GAAG5C,SAAS,CAAC/C,KAAV,CAAgB4F,IAAlC;AACA,UAAMzD,KAAK,GAAG,IAAIwD,SAAJ,CAAc5C,SAAS,CAAC/C,KAAxB,EAA+B;AAAC6F,MAAAA,OAAO,EAAEJ,UAAU;AAApB,KAA/B,CAAd;AACAb,IAAAA,MAAM,CAACkB,IAAP,CAAY3D,KAAZ;AACD,GAJD;AAKAtC,EAAAA,IAAI,CAAC+B,QAAL,CAAc;AAACgD,IAAAA;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":["Deck","WebMercatorViewport","MapView","_flatten","flatten","getDeckInstance","map","gl","deck","__deck","customRender","props","_customRender","deckProps","useDevicePixels","reason","triggerRepaint","parameters","depthMask","depthTest","blend","blendFunc","polygonOffsetFill","depthFunc","blendEquation","views","id","Object","assign","width","height","touchAction","viewState","getViewState","on","onMapMove","setProps","userData","isExternal","finalize","mapboxLayers","Set","mapboxVersion","getMapboxVersion","layerManager","afterRender","addLayer","layer","add","updateLayers","removeLayer","delete","updateLayer","drawLayer","currentViewport","getViewport","_drawLayers","viewports","layerFilter","deckLayer","clearCanvas","lng","lat","getCenter","longitude","latitude","zoom","getZoom","bearing","getBearing","pitch","getPitch","repeat","getRenderWorldCopies","major","minor","version","split","slice","Number","useMapboxProjection","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,SAAQA,IAAR,EAAcC,mBAAd,EAAmCC,OAAnC,EAA4CC,QAAQ,IAAIC,OAAxD,QAAsE,eAAtE;AAYA,OAAO,SAASC,eAAT,CAAyB;AAC9BC,EAAAA,GAD8B;AAE9BC,EAAAA,EAF8B;AAG9BC,EAAAA;AAH8B,CAAzB,EAQE;AAAA;;AAEP,MAAIF,GAAG,CAACG,MAAR,EAAgB;AACd,WAAOH,GAAG,CAACG,MAAX;AACD;;AAED,QAAMC,YAAY,YAAGF,IAAH,0CAAG,MAAMG,KAAN,CAAYC,aAAjC;AAEA,QAAMC,SAAoB,GAAG;AAC3BC,IAAAA,eAAe,EAAE,IADU;AAE3BF,IAAAA,aAAa,EAAGG,MAAD,IAAoB;AACjCT,MAAAA,GAAG,CAACU,cAAJ;AAGAN,MAAAA,YAAY,SAAZ,IAAAA,YAAY,WAAZ,YAAAA,YAAY,CAAGK,MAAH,CAAZ;AACD,KAP0B;AAS3BE,IAAAA,UAAU,EAAE;AACVC,MAAAA,S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AnB,GAAjB;AACD;;AAED,SAASrD,YAAT,CAAsBzC,IAAtB,EAAwC;AACtC,MAAKA,IAAI,CAAC6B,QAAN,CAA4BC,UAAhC,EAA4C;AAC1C;AACD;;AAED,QAAMkD,MAAe,GAAG,EAAxB;AACA,MAAIe,UAAU,GAAG,CAAjB;AACC/F,EAAAA,IAAI,CAAC6B,QAAN,CAA4BG,YAA5B,CAAyCgE,OAAzC,CAAiD7C,SAAS,IAAI;AAC5D,UAAM8C,SAAS,GAAG9C,SAAS,CAAChD,KAAV,CAAgB+F,IAAlC;AACA,UAAM3D,KAAK,GAAG,IAAI0D,SAAJ,CAAc9C,SAAS,CAAChD,KAAxB,EAA+B;AAACgG,MAAAA,OAAO,EAAEJ,UAAU;AAApB,KAA/B,CAAd;AACAf,IAAAA,MAAM,CAACoB,IAAP,CAAY7D,KAAZ;AACD,GAJD;AAKAvC,EAAAA,IAAI,CAAC4B,QAAL,CAAc;AAACoD,IAAAA;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"}
@@ -1,6 +1,19 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
1
2
  import { getDeckInstance, addLayer, removeLayer, updateLayer, drawLayer } from './deck-utils';
2
3
  export default class MapboxLayer {
3
4
  constructor(props) {
5
+ _defineProperty(this, "id", void 0);
6
+
7
+ _defineProperty(this, "type", void 0);
8
+
9
+ _defineProperty(this, "renderingMode", void 0);
10
+
11
+ _defineProperty(this, "map", void 0);
12
+
13
+ _defineProperty(this, "deck", void 0);
14
+
15
+ _defineProperty(this, "props", void 0);
16
+
4
17
  if (!props.id) {
5
18
  throw new Error('Layer must have an unique id');
6
19
  }
@@ -24,7 +37,9 @@ export default class MapboxLayer {
24
37
  }
25
38
 
26
39
  onRemove() {
27
- removeLayer(this.deck, this);
40
+ if (this.deck) {
41
+ removeLayer(this.deck, this);
42
+ }
28
43
  }
29
44
 
30
45
  setProps(props) {
@@ -37,7 +52,7 @@ export default class MapboxLayer {
37
52
  }
38
53
  }
39
54
 
40
- render(gl, matrix) {
55
+ render() {
41
56
  drawLayer(this.deck, this.map, this);
42
57
  }
43
58
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mapbox-layer.js"],"names":["getDeckInstance","addLayer","removeLayer","updateLayer","drawLayer","MapboxLayer","constructor","props","id","Error","type","renderingMode","map","deck","onAdd","gl","onRemove","setProps","Object","assign","render","matrix"],"mappings":"AAAA,SAAQA,eAAR,EAAyBC,QAAzB,EAAmCC,WAAnC,EAAgDC,WAAhD,EAA6DC,SAA7D,QAA6E,cAA7E;AAEA,eAAe,MAAMC,WAAN,CAAkB;AAE/BC,EAAAA,WAAW,CAACC,KAAD,EAAQ;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;;AAIDO,EAAAA,KAAK,CAACF,GAAD,EAAMG,EAAN,EAAU;AACb,SAAKH,GAAL,GAAWA,GAAX;AACA,SAAKC,IAAL,GAAYb,eAAe,CAAC;AAACY,MAAAA,GAAD;AAAMG,MAAAA,EAAN;AAAUF,MAAAA,IAAI,EAAE,KAAKN,KAAL,CAAWM;AAA3B,KAAD,CAA3B;AACAZ,IAAAA,QAAQ,CAAC,KAAKY,IAAN,EAAY,IAAZ,CAAR;AACD;;AAEDG,EAAAA,QAAQ,GAAG;AACTd,IAAAA,WAAW,CAAC,KAAKW,IAAN,EAAY,IAAZ,CAAX;AACD;;AAEDI,EAAAA,QAAQ,CAACV,KAAD,EAAQ;AAEdW,IAAAA,MAAM,CAACC,MAAP,CAAc,KAAKZ,KAAnB,EAA0BA,KAA1B,EAAiC;AAACC,MAAAA,EAAE,EAAE,KAAKA;AAAV,KAAjC;;AAEA,QAAI,KAAKK,IAAT,EAAe;AACbV,MAAAA,WAAW,CAAC,KAAKU,IAAN,EAAY,IAAZ,CAAX;AACD;AACF;;AAEDO,EAAAA,MAAM,CAACL,EAAD,EAAKM,MAAL,EAAa;AACjBjB,IAAAA,SAAS,CAAC,KAAKS,IAAN,EAAY,KAAKD,GAAjB,EAAsB,IAAtB,CAAT;AACD;;AAtC8B","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":["getDeckInstance","addLayer","removeLayer","updateLayer","drawLayer","MapboxLayer","constructor","props","id","Error","type","renderingMode","map","deck","onAdd","gl","onRemove","setProps","Object","assign","render"],"mappings":";AAAA,SAAQA,eAAR,EAAyBC,QAAzB,EAAmCC,WAAnC,EAAgDC,W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N,EAAa,KAAKD,GAAlB,EAAwB,IAAxB,CAAT;AACD;;AA/CoF","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"}
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { Deck } from '@deck.gl/core';
2
+ import { Deck, assert } from '@deck.gl/core';
3
3
  import { getViewState } from './deck-utils';
4
4
  export default class MapboxOverlay {
5
5
  constructor(props) {
@@ -32,7 +32,7 @@ export default class MapboxOverlay {
32
32
  deck.setProps({
33
33
  viewState: getViewState(this._map)
34
34
  });
35
- deck.redraw(false);
35
+ deck.redraw();
36
36
  }
37
37
  });
38
38
 
@@ -51,11 +51,10 @@ export default class MapboxOverlay {
51
51
 
52
52
  switch (event.type) {
53
53
  case 'click':
54
- deck._lastPointerDownInfo = deck.pickObject({ ...mockEvent.offsetCenter,
55
- radius: deck.props.pickingRadius
56
- });
57
54
  mockEvent.tapCount = 1;
58
55
 
56
+ deck._onPointerDown(mockEvent);
57
+
59
58
  deck._onEvent(mockEvent);
60
59
 
61
60
  break;
@@ -144,6 +143,7 @@ export default class MapboxOverlay {
144
143
  }
145
144
 
146
145
  (_this$_deck = this._deck) === null || _this$_deck === void 0 ? void 0 : _this$_deck.finalize();
146
+ this._deck = undefined;
147
147
  this._map = undefined;
148
148
  this._container = undefined;
149
149
  }
@@ -153,15 +153,18 @@ export default class MapboxOverlay {
153
153
  }
154
154
 
155
155
  pickObject(params) {
156
- return this._deck && this._deck.pickObject(params);
156
+ assert(this._deck);
157
+ return this._deck.pickObject(params);
157
158
  }
158
159
 
159
160
  pickMultipleObjects(params) {
160
- return this._deck && this._deck.pickMultipleObjects(params);
161
+ assert(this._deck);
162
+ return this._deck.pickMultipleObjects(params);
161
163
  }
162
164
 
163
165
  pickObjects(params) {
164
- return this._deck && this._deck.pickObjects(params);
166
+ assert(this._deck);
167
+ return this._deck.pickObjects(params);
165
168
  }
166
169
 
167
170
  finalize() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mapbox-overlay.ts"],"names":["Deck","getViewState","MapboxOverlay","constructor","props","_map","_container","clientWidth","clientHeight","getContainer","Object","assign","style","width","height","deck","_deck","setProps","viewState","redraw","event","mockEvent","type","offsetCenter","point","srcEvent","_lastPointerDownInfo","pickObject","radius","pickingRadius","tapCount","_onEvent","_onPointerMove","_props","onAdd","map","container","document","createElement","position","left","top","pointerEvents","parent","on","_updateContainerSize","_updateViewState","_handleMouseEvent","onRemove","off","finalize","undefined","getDefaultPosition","params","pickMultipleObjects","pickObjects","removeControl"],"mappings":";AAAA,SAAQA,I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wBAAK/B,KAAL,4DAAYkC,QAAZ;AACA,SAAK7C,IAAL,GAAY8C,SAAZ;AACA,SAAK7C,UAAL,GAAkB6C,SAAlB;AACD;;AAEDC,EAAAA,kBAAkB,GAAG;AACnB,WAAO,UAAP;AACD;;AAGDzB,EAAAA,UAAU,CAAC0B,MAAD,EAAS;AACjB,WAAO,KAAKrC,KAAL,IAAc,KAAKA,KAAL,CAAWW,UAAX,CAAsB0B,MAAtB,CAArB;AACD;;AAGDC,EAAAA,mBAAmB,CAACD,MAAD,EAAS;AAC1B,WAAO,KAAKrC,KAAL,IAAc,KAAKA,KAAL,CAAWsC,mBAAX,CAA+BD,MAA/B,CAArB;AACD;;AAGDE,EAAAA,WAAW,CAACF,MAAD,EAAS;AAClB,WAAO,KAAKrC,KAAL,IAAc,KAAKA,KAAL,CAAWuC,WAAX,CAAuBF,MAAvB,CAArB;AACD;;AAGDH,EAAAA,QAAQ,GAAG;AACT,QAAI,KAAK7C,IAAT,EAAe;AACb,WAAKA,IAAL,CAAUmD,aAAV,CAAwB,IAAxB;AACD;AACF;;AAhGoD","sourcesContent":["import {Deck} from '@deck.gl/core';\nimport {getViewState} from './deck-utils';\n\nimport type {Map, IControl, MapMouseEvent} from 'mapbox-gl';\n\n/**\n * Implements Mapbox [IControl](https://docs.mapbox.com/mapbox-gl-js/api/markers/#icontrol) interface\n * Renders deck.gl layers over the base map and automatically synchronizes with the map's camera\n */\nexport default class MapboxOverlay implements IControl {\n private _props: any;\n private _deck: Deck;\n private _map?: Map;\n private _container?: HTMLDivElement;\n\n constructor(props) {\n this._props = {...props};\n }\n\n /** Update (partial) props of the underlying Deck instance. */\n setProps(props: any): void {\n Object.assign(this._props, props);\n\n if ('viewState' in this._props) {\n delete this._props.viewState;\n }\n\n if (this._deck) {\n this._deck.setProps(this._props);\n }\n }\n\n /** Called when the control is added to a map */\n onAdd(map: Map) {\n this._map = map;\n\n /* global document */\n const container = document.createElement('div');\n Object.assign(container.style, {\n position: 'absolute',\n left: 0,\n top: 0,\n pointerEvents: 'none'\n });\n this._container = container;\n\n this._deck = new Deck({\n ...this._props,\n parent: container,\n viewState: getViewState(map)\n });\n\n map.on('resize', this._updateContainerSize);\n map.on('render', this._updateViewState);\n map.on('mousemove', this._handleMouseEvent);\n map.on('mouseout', this._handleMouseEvent);\n map.on('click', this._handleMouseEvent);\n map.on('dblclick', this._handleMouseEvent);\n\n this._updateContainerSize();\n return container;\n }\n\n /** Called when the control is removed from a map */\n onRemove() {\n const map = this._map;\n\n if (map) {\n map.off('resize', this._updateContainerSize);\n map.off('render', this._updateViewState);\n map.off('mousemove', this._handleMouseEvent);\n map.off('mouseout', this._handleMouseEvent);\n map.off('click', this._handleMouseEvent);\n map.off('dblclick', this._handleMouseEvent);\n }\n\n this._deck?.finalize();\n this._map = undefined;\n this._container = undefined;\n }\n\n getDefaultPosition() {\n return 'top-left';\n }\n\n /** Forwards the Deck.pickObject method */\n pickObject(params) {\n return this._deck && this._deck.pickObject(params);\n }\n\n /** Forwards the Deck.pickMultipleObjects method */\n pickMultipleObjects(params) {\n return this._deck && this._deck.pickMultipleObjects(params);\n }\n\n /** Forwards the Deck.pickObjects method */\n pickObjects(params) {\n return this._deck && this._deck.pickObjects(params);\n }\n\n /** Remove from map and releases all resources */\n finalize() {\n if (this._map) {\n this._map.removeControl(this);\n }\n }\n\n _updateContainerSize = () => {\n if (this._map && this._container) {\n const {clientWidth, clientHeight} = this._map.getContainer();\n Object.assign(this._container.style, {\n width: `${clientWidth}px`,\n height: `${clientHeight}px`\n });\n }\n };\n\n _updateViewState = () => {\n const deck = this._deck;\n if (deck) {\n deck.setProps({viewState: getViewState(this._map)});\n // Redraw immediately if view state has changed\n deck.redraw(false);\n }\n };\n\n _handleMouseEvent = (event: MapMouseEvent) => {\n const deck = this._deck;\n if (!deck) {\n return;\n }\n\n const mockEvent: {\n type: string;\n offsetCenter: {x: number; y: number};\n srcEvent: MapMouseEvent;\n tapCount?: number;\n } = {\n type: event.type,\n offsetCenter: event.point,\n srcEvent: event\n };\n\n switch (event.type) {\n case 'click':\n // Hack: because we do not listen to pointer down, perform picking now\n deck._lastPointerDownInfo = deck.pickObject({\n ...mockEvent.offsetCenter,\n radius: deck.props.pickingRadius\n });\n mockEvent.tapCount = 1;\n deck._onEvent(mockEvent);\n break;\n\n case 'dblclick':\n mockEvent.type = 'click';\n mockEvent.tapCount = 2;\n deck._onEvent(mockEvent);\n break;\n\n case 'mousemove':\n mockEvent.type = 'pointermove';\n deck._onPointerMove(mockEvent);\n break;\n\n case 'mouseout':\n mockEvent.type = 'pointerleave';\n deck._onPointerMove(mockEvent);\n break;\n\n default:\n return;\n }\n };\n}\n"],"file":"mapbox-overlay.js"}
1
+ {"version":3,"sources":["../../src/mapbox-overlay.ts"],"names":["Deck","assert","getViewState","MapboxOverlay","constructor","props","_map","_container","clientWidth","clientHeight","getContainer","Object","assign","style","width","height","deck","_deck","setProps","viewState","redraw","event","mockEvent","type","offsetCenter","point","srcEvent","tapCount","_onPointerDown","_onEvent","_onPointerMove","_props","onAdd","map","container","document","createElement","position","left","top","pointerEvents","parent","on","_updateContainerSize","_updateViewState","_handleMouseEvent","onRemove","off","finalize","undefined","getDefaultPosition","pickObject","params","pickMultipleObjects","pickObjects","removeControl"],"mappings":";AAAA,SAAQA,IAAR,EAAcC,MAAd,QAA2B,eAA3B;AACA,SAAQC,YAAR,QAA2B,cAA3B;AAUA,eAAe,MAAMC,aAAN,CAAwC;AAMrDC,EAAAA,WAAW,CAACC,KAAD,EAAmB;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,kDAkGC,MAAM;AACnC,UAAI,KAAKC,IAAL,IAAa,KAAKC,UAAtB,EAAkC;AAChC,cAAM;AAACC,UAAAA,WAAD;AAAcC,UAAAA;AAAd,YAA8B,KAAKH,IAAL,CAAUI,YAAV,EAApC;;AACAC,QAAAA,MAAM,CAACC,MAAP,CAAc,KAAKL,UAAL,CAAgBM,KAA9B,EAAqC;AACnCC,UAAAA,KAAK,YAAKN,WAA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AAC,KAAKgB,KAAN,CAAN;AACA,WAAO,KAAKA,KAAL,CAAWqC,WAAX,CAAuBF,MAAvB,CAAP;AACD;;AAGDJ,EAAAA,QAAQ,GAAG;AACT,QAAI,KAAK1C,IAAT,EAAe;AACb,WAAKA,IAAL,CAAUiD,aAAV,CAAwB,IAAxB;AACD;AACF;;AAtGoD","sourcesContent":["import {Deck, assert} from '@deck.gl/core';\nimport {getViewState} from './deck-utils';\n\nimport type {Map, IControl, MapMouseEvent} from 'mapbox-gl';\nimport type {MjolnirGestureEvent, MjolnirPointerEvent} from 'mjolnir.js';\nimport type {DeckProps} from '@deck.gl/core';\n\n/**\n * Implements Mapbox [IControl](https://docs.mapbox.com/mapbox-gl-js/api/markers/#icontrol) interface\n * Renders deck.gl layers over the base map and automatically synchronizes with the map's camera\n */\nexport default class MapboxOverlay implements IControl {\n private _props: DeckProps;\n private _deck?: Deck;\n private _map?: Map;\n private _container?: HTMLDivElement;\n\n constructor(props: DeckProps) {\n this._props = {...props};\n }\n\n /** Update (partial) props of the underlying Deck instance. */\n setProps(props: DeckProps): void {\n Object.assign(this._props, props);\n\n if ('viewState' in this._props) {\n delete this._props.viewState;\n }\n\n if (this._deck) {\n this._deck.setProps(this._props);\n }\n }\n\n /** Called when the control is added to a map */\n onAdd(map: Map): HTMLDivElement {\n this._map = map;\n\n /* global document */\n const container = document.createElement('div');\n Object.assign(container.style, {\n position: 'absolute',\n left: 0,\n top: 0,\n pointerEvents: 'none'\n });\n this._container = container;\n\n this._deck = new Deck({\n ...this._props,\n parent: container,\n viewState: getViewState(map)\n });\n\n map.on('resize', this._updateContainerSize);\n map.on('render', this._updateViewState);\n map.on('mousemove', this._handleMouseEvent);\n map.on('mouseout', this._handleMouseEvent);\n map.on('click', this._handleMouseEvent);\n map.on('dblclick', this._handleMouseEvent);\n\n this._updateContainerSize();\n return container;\n }\n\n /** Called when the control is removed from a map */\n onRemove(): void {\n const map = this._map;\n\n if (map) {\n map.off('resize', this._updateContainerSize);\n map.off('render', this._updateViewState);\n map.off('mousemove', this._handleMouseEvent);\n map.off('mouseout', this._handleMouseEvent);\n map.off('click', this._handleMouseEvent);\n map.off('dblclick', this._handleMouseEvent);\n }\n\n this._deck?.finalize();\n this._deck = undefined;\n this._map = undefined;\n this._container = undefined;\n }\n\n getDefaultPosition() {\n return 'top-left';\n }\n\n /** Forwards the Deck.pickObject method */\n pickObject(params: Parameters<Deck['pickObject']>[0]): ReturnType<Deck['pickObject']> {\n assert(this._deck);\n return this._deck.pickObject(params);\n }\n\n /** Forwards the Deck.pickMultipleObjects method */\n pickMultipleObjects(\n params: Parameters<Deck['pickMultipleObjects']>[0]\n ): ReturnType<Deck['pickMultipleObjects']> {\n assert(this._deck);\n return this._deck.pickMultipleObjects(params);\n }\n\n /** Forwards the Deck.pickObjects method */\n pickObjects(params: Parameters<Deck['pickObjects']>[0]): ReturnType<Deck['pickObjects']> {\n assert(this._deck);\n return this._deck.pickObjects(params);\n }\n\n /** Remove from map and releases all resources */\n finalize() {\n if (this._map) {\n this._map.removeControl(this);\n }\n }\n\n private _updateContainerSize = () => {\n if (this._map && this._container) {\n const {clientWidth, clientHeight} = this._map.getContainer();\n Object.assign(this._container.style, {\n width: `${clientWidth}px`,\n height: `${clientHeight}px`\n });\n }\n };\n\n private _updateViewState = () => {\n const deck = this._deck;\n if (deck) {\n // @ts-ignore (2345) map is always defined if deck is\n deck.setProps({viewState: getViewState(this._map)});\n // Redraw immediately if view state has changed\n deck.redraw();\n }\n };\n\n private _handleMouseEvent = (event: MapMouseEvent) => {\n const deck = this._deck;\n if (!deck) {\n return;\n }\n\n const mockEvent: {\n type: string;\n offsetCenter: {x: number; y: number};\n srcEvent: MapMouseEvent;\n tapCount?: number;\n } = {\n type: event.type,\n offsetCenter: event.point,\n srcEvent: event\n };\n\n switch (event.type) {\n case 'click':\n mockEvent.tapCount = 1;\n // Hack: because we do not listen to pointer down, perform picking now\n deck._onPointerDown(mockEvent as MjolnirGestureEvent);\n deck._onEvent(mockEvent as MjolnirGestureEvent);\n break;\n\n case 'dblclick':\n mockEvent.type = 'click';\n mockEvent.tapCount = 2;\n deck._onEvent(mockEvent as MjolnirGestureEvent);\n break;\n\n case 'mousemove':\n mockEvent.type = 'pointermove';\n deck._onPointerMove(mockEvent as MjolnirPointerEvent);\n break;\n\n case 'mouseout':\n mockEvent.type = 'pointerleave';\n deck._onPointerMove(mockEvent as MjolnirPointerEvent);\n break;\n\n default:\n return;\n }\n };\n}\n"],"file":"mapbox-overlay.js"}
package/dist.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("deck")):"function"==typeof define&&define.amd?define(["deck"],t):"object"==typeof exports?exports.deck=t(require("deck")):e.deck=t(e.deck)}(window,(function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(t,n){t.exports=e},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},function(e,t,n){var r=n(6),i=n(7),o=n(8);e.exports=function(e,t){return r(e)||i(e,t)||o()}},function(e,t,n){var r=n(9),i=globalThis.deck||{};if(!i.Layer)throw new Error("@deck.gl/core is not found");e.exports=Object.assign(i,r)},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,t,n){"use strict";n.r(t);var r=n(2),i=n.n(r),o=n(3),a=n.n(o),s=n(4),u=n.n(s),c=n(1);function p(e){var t=e.map,n=e.gl,r=e.deck;if(t.__deck)return t.__deck;var i=r&&r.props._customRender,o={useDevicePixels:!0,_customRender:function(){t.triggerRepaint(),i&&i()},parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774},userData:{isExternal:!1,mapboxLayers:new Set},views:r&&r.props.views||[new c.MapView({id:"mapbox"})]};return r&&r.props.gl!==n||(Object.assign(o,{gl:n,width:!1,height:!1,touchAction:"unset",viewState:l(t)}),t.on("move",(function(){return function(e,t){e.setProps({viewState:l(t)}),e.needsRedraw({clearRedrawFlags:!0})}(r,t)}))),r?(r.setProps(o),r.props.userData.isExternal=!0):(r=new c.Deck(o),t.on("remove",(function(){r.finalize(),t.__deck=null}))),r.props.userData.mapboxVersion=function(e){var t=0,n=0;if(e.version){var r=e.version.split(".").slice(0,2).map(Number),i=u()(r,2);t=i[0],n=i[1]}return{major:t,minor:n}}(t),t.__deck=r,t.on("render",(function(){r.layerManager&&function(e,t){var n=e.props.userData,r=n.mapboxLayers;if(n.isExternal){var i=Array.from(r,(function(e){return e.id})),o=e.props.layers.some((function(e){return!i.includes(e.id)})),a=e.getViewports(),s=a.findIndex((function(e){return"mapbox"===e.id})),u=a.length>1||s<0;(o||u)&&(s>=0&&((a=a.slice())[s]=d(e,t,!1)),e._drawLayers("mapbox-repaint",{viewports:a,layerFilter:function(t){return(!e.props.layerFilter||e.props.layerFilter(t))&&("mapbox"!==t.viewport.id||!i.includes(t.layer.id))},clearCanvas:!1}))}e.props.userData.currentViewport=null}(r,t)})),r}function l(e){var t=e.getCenter();return{longitude:(t.lng+540)%360-180,latitude:t.lat,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),repeat:e.getRenderWorldCopies()}}function d(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=e.props.userData.mapboxVersion;return new c.WebMercatorViewport(Object.assign({id:"mapbox",x:0,y:0,width:e.width,height:e.height},l(t),n?{nearZMultiplier:1===r.major&&r.minor>=3||r.major>=2?.02:1/(e.height||1)}:{nearZMultiplier:.1}))}function f(e){if(!e.props.userData.isExternal){var t=[],n=0;e.props.userData.mapboxLayers.forEach((function(e){var r=new(0,e.props.type)(e.props,{_offset:n++});t.push(r)})),e.setProps({layers:t})}}var h=function(){function e(t){if(i()(this,e),!t.id)throw new Error("Layer must have an unique id");this.id=t.id,this.type="custom",this.renderingMode=t.renderingMode||"3d",this.map=null,this.deck=null,this.props=t}return a()(e,[{key:"onAdd",value:function(e,t){var n,r;this.map=e,this.deck=p({map:e,gl:t,deck:this.props.deck}),n=this.deck,r=this,n.props.userData.mapboxLayers.add(r),f(n)}},{key:"onRemove",value:function(){var e,t;e=this.deck,t=this,e.props.userData.mapboxLayers.delete(t),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,t){var n,r,i,o;n=this.deck,r=this.map,i=this,(o=n.props.userData.currentViewport)||(o=d(n,r,!0),n.props.userData.currentViewport=o),n.layerManager&&n._drawLayers("mapbox-repaint",{viewports:[o],layerFilter:function(e){var t=e.layer;return i.id===t.id},clearCanvas:!1})}}]),e}(),v=n(0),b=n.n(v);function y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?y(Object(n),!0).forEach((function(t){b()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var _=function(){function e(t){var n=this;i()(this,e),b()(this,"_props",void 0),b()(this,"_deck",void 0),b()(this,"_map",void 0),b()(this,"_container",void 0),b()(this,"_updateContainerSize",(function(){if(n._map&&n._container){var e=n._map.getContainer(),t=e.clientWidth,r=e.clientHeight;Object.assign(n._container.style,{width:"".concat(t,"px"),height:"".concat(r,"px")})}})),b()(this,"_updateViewState",(function(){var e=n._deck;e&&(e.setProps({viewState:l(n._map)}),e.redraw(!1))})),b()(this,"_handleMouseEvent",(function(e){var t=n._deck;if(t){var r={type:e.type,offsetCenter:e.point,srcEvent:e};switch(e.type){case"click":t._lastPointerDownInfo=t.pickObject(m(m({},r.offsetCenter),{},{radius:t.props.pickingRadius})),r.tapCount=1,t._onEvent(r);break;case"dblclick":r.type="click",r.tapCount=2,t._onEvent(r);break;case"mousemove":r.type="pointermove",t._onPointerMove(r);break;case"mouseout":r.type="pointerleave",t._onPointerMove(r);break;default:return}}})),this._props=m({},t)}return a()(e,[{key:"setProps",value:function(e){Object.assign(this._props,e),"viewState"in this._props&&delete this._props.viewState,this._deck&&this._deck.setProps(this._props)}},{key:"onAdd",value:function(e){this._map=e;var t=document.createElement("div");return Object.assign(t.style,{position:"absolute",left:0,top:0,pointerEvents:"none"}),this._container=t,this._deck=new c.Deck(m(m({},this._props),{},{parent:t,viewState:l(e)})),e.on("resize",this._updateContainerSize),e.on("render",this._updateViewState),e.on("mousemove",this._handleMouseEvent),e.on("mouseout",this._handleMouseEvent),e.on("click",this._handleMouseEvent),e.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),t}},{key:"onRemove",value:function(){var e,t=this._map;t&&(t.off("resize",this._updateContainerSize),t.off("render",this._updateViewState),t.off("mousemove",this._handleMouseEvent),t.off("mouseout",this._handleMouseEvent),t.off("click",this._handleMouseEvent),t.off("dblclick",this._handleMouseEvent)),null===(e=this._deck)||void 0===e||e.finalize(),this._map=void 0,this._container=void 0}},{key:"getDefaultPosition",value:function(){return"top-left"}},{key:"pickObject",value:function(e){return this._deck&&this._deck.pickObject(e)}},{key:"pickMultipleObjects",value:function(e){return this._deck&&this._deck.pickMultipleObjects(e)}},{key:"pickObjects",value:function(e){return this._deck&&this._deck.pickObjects(e)}},{key:"finalize",value:function(){this._map&&this._map.removeControl(this)}}]),e}();n.d(t,"MapboxLayer",(function(){return h})),n.d(t,"MapboxOverlay",(function(){return _}))}])}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("deck")):"function"==typeof define&&define.amd?define(["deck"],t):"object"==typeof exports?exports.deck=t(require("deck")):e.deck=t(e.deck)}(window,(function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(t,n){t.exports=e},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},function(e,t,n){var r=n(6),i=n(7),o=n(8);e.exports=function(e,t){return r(e)||i(e,t)||o()}},function(e,t,n){var r=n(9),i=globalThis.deck||{};if(!i.Layer)throw new Error("@deck.gl/core is not found");e.exports=Object.assign(i,r)},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,t,n){"use strict";n.r(t);var r=n(2),i=n.n(r),o=n(3),a=n.n(o),s=n(0),u=n.n(s),c=n(4),p=n.n(c),l=n(1);function d(e){var t,n=e.map,r=e.gl,i=e.deck;if(n.__deck)return n.__deck;var o=null===(t=i)||void 0===t?void 0:t.props._customRender,a={useDevicePixels:!0,_customRender:function(e){n.triggerRepaint(),null==o||o(e)},parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774},views:i&&i.props.views||[new l.MapView({id:"mapbox"})]};return i&&i.props.gl!==r||(Object.assign(a,{gl:r,width:null,height:null,touchAction:"unset",viewState:f(n)}),n.on("move",(function(){return function(e,t){e.setProps({viewState:f(t)}),e.needsRedraw({clearRedrawFlags:!0})}(i,n)}))),i?(i.setProps(a),i.userData.isExternal=!0):(i=new l.Deck(a),n.on("remove",(function(){i.finalize(),n.__deck=null}))),i.userData.mapboxLayers=new Set,i.userData.mapboxVersion=function(e){var t=0,n=0,r=e.version;if(r){var i=r.split(".").slice(0,2).map(Number),o=p()(i,2);t=o[0],n=o[1]}return{major:t,minor:n}}(n),n.__deck=i,n.on("render",(function(){i.layerManager&&function(e,t){var n=e.userData,r=n.mapboxLayers;if(n.isExternal){var i=Array.from(r,(function(e){return e.id})),o=Object(l._flatten)(e.props.layers,Boolean).some((function(e){return e&&!i.includes(e.id)})),a=e.getViewports(),s=a.findIndex((function(e){return"mapbox"===e.id})),u=a.length>1||s<0;(o||u)&&(s>=0&&((a=a.slice())[s]=h(e,t,!1)),e._drawLayers("mapbox-repaint",{viewports:a,layerFilter:function(t){return(!e.props.layerFilter||e.props.layerFilter(t))&&("mapbox"!==t.viewport.id||!i.includes(t.layer.id))},clearCanvas:!1}))}e.userData.currentViewport=null}(i,n)})),i}function f(e){var t=e.getCenter();return{longitude:(t.lng+540)%360-180,latitude:t.lat,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),repeat:e.getRenderWorldCopies()}}function h(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=e.userData,i=r.mapboxVersion;return new l.WebMercatorViewport(Object.assign({id:"mapbox",x:0,y:0,width:e.width,height:e.height},f(t),n?{nearZMultiplier:1===i.major&&i.minor>=3||i.major>=2?.02:1/(e.height||1)}:{nearZMultiplier:.1}))}function v(e){if(!e.userData.isExternal){var t=[],n=0;e.userData.mapboxLayers.forEach((function(e){var r=new(0,e.props.type)(e.props,{_offset:n++});t.push(r)})),e.setProps({layers:t})}}var b=function(){function e(t){if(i()(this,e),u()(this,"id",void 0),u()(this,"type",void 0),u()(this,"renderingMode",void 0),u()(this,"map",void 0),u()(this,"deck",void 0),u()(this,"props",void 0),!t.id)throw new Error("Layer must have an unique id");this.id=t.id,this.type="custom",this.renderingMode=t.renderingMode||"3d",this.map=null,this.deck=null,this.props=t}return a()(e,[{key:"onAdd",value:function(e,t){var n,r;this.map=e,this.deck=d({map:e,gl:t,deck:this.props.deck}),n=this.deck,r=this,n.userData.mapboxLayers.add(r),v(n)}},{key:"onRemove",value:function(){var e,t;this.deck&&(e=this.deck,t=this,e.userData.mapboxLayers.delete(t),v(e))}},{key:"setProps",value:function(e){Object.assign(this.props,e,{id:this.id}),this.deck&&v(this.deck)}},{key:"render",value:function(){var e,t,n,r;e=this.deck,t=this.map,n=this,(r=e.userData.currentViewport)||(r=h(e,t,!0),e.userData.currentViewport=r),e.layerManager&&e._drawLayers("mapbox-repaint",{viewports:[r],layerFilter:function(e){var t=e.layer;return n.id===t.id},clearCanvas:!1})}}]),e}();function y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?y(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var _=function(){function e(t){var n=this;i()(this,e),u()(this,"_props",void 0),u()(this,"_deck",void 0),u()(this,"_map",void 0),u()(this,"_container",void 0),u()(this,"_updateContainerSize",(function(){if(n._map&&n._container){var e=n._map.getContainer(),t=e.clientWidth,r=e.clientHeight;Object.assign(n._container.style,{width:"".concat(t,"px"),height:"".concat(r,"px")})}})),u()(this,"_updateViewState",(function(){var e=n._deck;e&&(e.setProps({viewState:f(n._map)}),e.redraw())})),u()(this,"_handleMouseEvent",(function(e){var t=n._deck;if(t){var r={type:e.type,offsetCenter:e.point,srcEvent:e};switch(e.type){case"click":r.tapCount=1,t._onPointerDown(r),t._onEvent(r);break;case"dblclick":r.type="click",r.tapCount=2,t._onEvent(r);break;case"mousemove":r.type="pointermove",t._onPointerMove(r);break;case"mouseout":r.type="pointerleave",t._onPointerMove(r);break;default:return}}})),this._props=m({},t)}return a()(e,[{key:"setProps",value:function(e){Object.assign(this._props,e),"viewState"in this._props&&delete this._props.viewState,this._deck&&this._deck.setProps(this._props)}},{key:"onAdd",value:function(e){this._map=e;var t=document.createElement("div");return Object.assign(t.style,{position:"absolute",left:0,top:0,pointerEvents:"none"}),this._container=t,this._deck=new l.Deck(m(m({},this._props),{},{parent:t,viewState:f(e)})),e.on("resize",this._updateContainerSize),e.on("render",this._updateViewState),e.on("mousemove",this._handleMouseEvent),e.on("mouseout",this._handleMouseEvent),e.on("click",this._handleMouseEvent),e.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),t}},{key:"onRemove",value:function(){var e,t=this._map;t&&(t.off("resize",this._updateContainerSize),t.off("render",this._updateViewState),t.off("mousemove",this._handleMouseEvent),t.off("mouseout",this._handleMouseEvent),t.off("click",this._handleMouseEvent),t.off("dblclick",this._handleMouseEvent)),null===(e=this._deck)||void 0===e||e.finalize(),this._deck=void 0,this._map=void 0,this._container=void 0}},{key:"getDefaultPosition",value:function(){return"top-left"}},{key:"pickObject",value:function(e){return Object(l.assert)(this._deck),this._deck.pickObject(e)}},{key:"pickMultipleObjects",value:function(e){return Object(l.assert)(this._deck),this._deck.pickMultipleObjects(e)}},{key:"pickObjects",value:function(e){return Object(l.assert)(this._deck),this._deck.pickObjects(e)}},{key:"finalize",value:function(){this._map&&this._map.removeControl(this)}}]),e}();n.d(t,"MapboxLayer",(function(){return b})),n.d(t,"MapboxOverlay",(function(){return _}))}])}));
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.8.0-alpha.4",
5
+ "version": "8.8.0-beta.1",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -21,6 +21,7 @@
21
21
  "files": [
22
22
  "dist",
23
23
  "src",
24
+ "typed",
24
25
  "dist.min.js"
25
26
  ],
26
27
  "sideEffects": false,
@@ -34,5 +35,5 @@
34
35
  "peerDependencies": {
35
36
  "@deck.gl/core": "^8.0.0"
36
37
  },
37
- "gitHead": "608c74fff3c955142c4e1f5e77b9e21ebbf690f7"
38
+ "gitHead": "1e4621a4f7422a053a74dcd8a175f9b56c273a14"
38
39
  }