@sigma/layer-maplibre 3.0.0-beta.3 → 3.0.0-beta.5

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.
@@ -1,3 +1,3 @@
1
- export * from "./declarations/src/index";
2
- export { default } from "./declarations/src/index";
1
+ export * from "./declarations/src/index.js";
2
+ export { default } from "./declarations/src/index.js";
3
3
  //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbWEtbGF5ZXItbWFwbGlicmUuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuL2RlY2xhcmF0aW9ucy9zcmMvaW5kZXguZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
@@ -3,9 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var maplibreGl = require('maplibre-gl');
6
- var settings = require('sigma/settings');
7
6
 
8
- function toPrimitive(t, r) {
7
+ function _toPrimitive(t, r) {
9
8
  if ("object" != typeof t || !t) return t;
10
9
  var e = t[Symbol.toPrimitive];
11
10
  if (void 0 !== e) {
@@ -16,24 +15,18 @@ function toPrimitive(t, r) {
16
15
  return ("string" === r ? String : Number)(t);
17
16
  }
18
17
 
19
- function toPropertyKey(t) {
20
- var i = toPrimitive(t, "string");
21
- return "symbol" == typeof i ? i : String(i);
18
+ function _toPropertyKey(t) {
19
+ var i = _toPrimitive(t, "string");
20
+ return "symbol" == typeof i ? i : i + "";
22
21
  }
23
22
 
24
- function _defineProperty(obj, key, value) {
25
- key = toPropertyKey(key);
26
- if (key in obj) {
27
- Object.defineProperty(obj, key, {
28
- value: value,
29
- enumerable: true,
30
- configurable: true,
31
- writable: true
32
- });
33
- } else {
34
- obj[key] = value;
35
- }
36
- return obj;
23
+ function _defineProperty(e, r, t) {
24
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
25
+ value: t,
26
+ enumerable: !0,
27
+ configurable: !0,
28
+ writable: !0
29
+ }) : e[r] = t, e;
37
30
  }
38
31
 
39
32
  function ownKeys(e, r) {
@@ -144,6 +137,10 @@ function syncMapWithSigma(sigma, map) {
144
137
  * @param opts.getNodeLatLng Function to retrieve lat/long values from a node's attributs (default is lat & lng)
145
138
  */
146
139
  function bindMaplibreLayer(sigma, opts) {
140
+ // Keeping data for the cleanup
141
+ var isKilled = false;
142
+ var prevSigmaSettings = sigma.getSettings();
143
+
147
144
  // Creating map container
148
145
  var mapContainer = document.createElement("div");
149
146
  var mapContainerId = "".concat(sigma.getContainer().id, "-map");
@@ -152,14 +149,14 @@ function bindMaplibreLayer(sigma, opts) {
152
149
  sigma.getContainer().appendChild(mapContainer);
153
150
 
154
151
  // Initialize the map
155
- var map = new maplibreGl.Map(_objectSpread2(_objectSpread2({}, (opts === null || opts === void 0 ? void 0 : opts.mapOptions) || {}), {}, {
152
+ var map = new maplibreGl.Map(_objectSpread2({
156
153
  container: mapContainerId,
157
154
  style: "https://demotiles.maplibre.org/style.json",
158
155
  center: [0, 0],
159
156
  zoom: 1,
160
157
  minPitch: 0,
161
158
  maxPitch: 0
162
- }));
159
+ }, (opts === null || opts === void 0 ? void 0 : opts.mapOptions) || {}));
163
160
 
164
161
  // `stagePadding: 0` is mandatory, so the bbox of the map & Sigma is the same.
165
162
  sigma.setSetting("stagePadding", 0);
@@ -215,13 +212,18 @@ function bindMaplibreLayer(sigma, opts) {
215
212
 
216
213
  // Clean up function to remove everything
217
214
  function clean() {
218
- map.off("moveend", fnSyncSigmaWithMap);
219
- map.remove();
220
- mapContainer.remove();
221
- sigma.off("afterRender", fnSyncMapWithSigma);
222
- sigma.off("resize", fnOnResize);
223
- sigma.setSetting("stagePadding", settings.DEFAULT_SETTINGS.stagePadding);
224
- sigma.setSetting("enableCameraRotation", true);
215
+ if (!isKilled) {
216
+ isKilled = true;
217
+ map.off("moveend", fnSyncSigmaWithMap);
218
+ map.remove();
219
+ mapContainer.remove();
220
+ sigma.off("afterRender", fnSyncMapWithSigma);
221
+ sigma.off("resize", fnOnResize);
222
+
223
+ // Reset settings
224
+ sigma.setSetting("stagePadding", prevSigmaSettings.stagePadding);
225
+ sigma.setSetting("enableCameraRotation", prevSigmaSettings.enableCameraRotation);
226
+ }
225
227
  }
226
228
 
227
229
  // Update the sigma graph for geospatial coords
@@ -3,9 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var maplibreGl = require('maplibre-gl');
6
- var settings = require('sigma/settings');
7
6
 
8
- function toPrimitive(t, r) {
7
+ function _toPrimitive(t, r) {
9
8
  if ("object" != typeof t || !t) return t;
10
9
  var e = t[Symbol.toPrimitive];
11
10
  if (void 0 !== e) {
@@ -16,24 +15,18 @@ function toPrimitive(t, r) {
16
15
  return ("string" === r ? String : Number)(t);
17
16
  }
18
17
 
19
- function toPropertyKey(t) {
20
- var i = toPrimitive(t, "string");
21
- return "symbol" == typeof i ? i : String(i);
18
+ function _toPropertyKey(t) {
19
+ var i = _toPrimitive(t, "string");
20
+ return "symbol" == typeof i ? i : i + "";
22
21
  }
23
22
 
24
- function _defineProperty(obj, key, value) {
25
- key = toPropertyKey(key);
26
- if (key in obj) {
27
- Object.defineProperty(obj, key, {
28
- value: value,
29
- enumerable: true,
30
- configurable: true,
31
- writable: true
32
- });
33
- } else {
34
- obj[key] = value;
35
- }
36
- return obj;
23
+ function _defineProperty(e, r, t) {
24
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
25
+ value: t,
26
+ enumerable: !0,
27
+ configurable: !0,
28
+ writable: !0
29
+ }) : e[r] = t, e;
37
30
  }
38
31
 
39
32
  function ownKeys(e, r) {
@@ -144,6 +137,10 @@ function syncMapWithSigma(sigma, map) {
144
137
  * @param opts.getNodeLatLng Function to retrieve lat/long values from a node's attributs (default is lat & lng)
145
138
  */
146
139
  function bindMaplibreLayer(sigma, opts) {
140
+ // Keeping data for the cleanup
141
+ var isKilled = false;
142
+ var prevSigmaSettings = sigma.getSettings();
143
+
147
144
  // Creating map container
148
145
  var mapContainer = document.createElement("div");
149
146
  var mapContainerId = "".concat(sigma.getContainer().id, "-map");
@@ -152,14 +149,14 @@ function bindMaplibreLayer(sigma, opts) {
152
149
  sigma.getContainer().appendChild(mapContainer);
153
150
 
154
151
  // Initialize the map
155
- var map = new maplibreGl.Map(_objectSpread2(_objectSpread2({}, (opts === null || opts === void 0 ? void 0 : opts.mapOptions) || {}), {}, {
152
+ var map = new maplibreGl.Map(_objectSpread2({
156
153
  container: mapContainerId,
157
154
  style: "https://demotiles.maplibre.org/style.json",
158
155
  center: [0, 0],
159
156
  zoom: 1,
160
157
  minPitch: 0,
161
158
  maxPitch: 0
162
- }));
159
+ }, (opts === null || opts === void 0 ? void 0 : opts.mapOptions) || {}));
163
160
 
164
161
  // `stagePadding: 0` is mandatory, so the bbox of the map & Sigma is the same.
165
162
  sigma.setSetting("stagePadding", 0);
@@ -215,13 +212,18 @@ function bindMaplibreLayer(sigma, opts) {
215
212
 
216
213
  // Clean up function to remove everything
217
214
  function clean() {
218
- map.off("moveend", fnSyncSigmaWithMap);
219
- map.remove();
220
- mapContainer.remove();
221
- sigma.off("afterRender", fnSyncMapWithSigma);
222
- sigma.off("resize", fnOnResize);
223
- sigma.setSetting("stagePadding", settings.DEFAULT_SETTINGS.stagePadding);
224
- sigma.setSetting("enableCameraRotation", true);
215
+ if (!isKilled) {
216
+ isKilled = true;
217
+ map.off("moveend", fnSyncSigmaWithMap);
218
+ map.remove();
219
+ mapContainer.remove();
220
+ sigma.off("afterRender", fnSyncMapWithSigma);
221
+ sigma.off("resize", fnOnResize);
222
+
223
+ // Reset settings
224
+ sigma.setSetting("stagePadding", prevSigmaSettings.stagePadding);
225
+ sigma.setSetting("enableCameraRotation", prevSigmaSettings.enableCameraRotation);
226
+ }
225
227
  }
226
228
 
227
229
  // Update the sigma graph for geospatial coords
@@ -1,7 +1,6 @@
1
1
  import { MercatorCoordinate, LngLatBounds, Map, LngLat } from 'maplibre-gl';
2
- import { DEFAULT_SETTINGS } from 'sigma/settings';
3
2
 
4
- function toPrimitive(t, r) {
3
+ function _toPrimitive(t, r) {
5
4
  if ("object" != typeof t || !t) return t;
6
5
  var e = t[Symbol.toPrimitive];
7
6
  if (void 0 !== e) {
@@ -12,24 +11,18 @@ function toPrimitive(t, r) {
12
11
  return ("string" === r ? String : Number)(t);
13
12
  }
14
13
 
15
- function toPropertyKey(t) {
16
- var i = toPrimitive(t, "string");
17
- return "symbol" == typeof i ? i : String(i);
14
+ function _toPropertyKey(t) {
15
+ var i = _toPrimitive(t, "string");
16
+ return "symbol" == typeof i ? i : i + "";
18
17
  }
19
18
 
20
- function _defineProperty(obj, key, value) {
21
- key = toPropertyKey(key);
22
- if (key in obj) {
23
- Object.defineProperty(obj, key, {
24
- value: value,
25
- enumerable: true,
26
- configurable: true,
27
- writable: true
28
- });
29
- } else {
30
- obj[key] = value;
31
- }
32
- return obj;
19
+ function _defineProperty(e, r, t) {
20
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
21
+ value: t,
22
+ enumerable: !0,
23
+ configurable: !0,
24
+ writable: !0
25
+ }) : e[r] = t, e;
33
26
  }
34
27
 
35
28
  function ownKeys(e, r) {
@@ -140,6 +133,10 @@ function syncMapWithSigma(sigma, map) {
140
133
  * @param opts.getNodeLatLng Function to retrieve lat/long values from a node's attributs (default is lat & lng)
141
134
  */
142
135
  function bindMaplibreLayer(sigma, opts) {
136
+ // Keeping data for the cleanup
137
+ var isKilled = false;
138
+ var prevSigmaSettings = sigma.getSettings();
139
+
143
140
  // Creating map container
144
141
  var mapContainer = document.createElement("div");
145
142
  var mapContainerId = "".concat(sigma.getContainer().id, "-map");
@@ -148,14 +145,14 @@ function bindMaplibreLayer(sigma, opts) {
148
145
  sigma.getContainer().appendChild(mapContainer);
149
146
 
150
147
  // Initialize the map
151
- var map = new Map(_objectSpread2(_objectSpread2({}, (opts === null || opts === void 0 ? void 0 : opts.mapOptions) || {}), {}, {
148
+ var map = new Map(_objectSpread2({
152
149
  container: mapContainerId,
153
150
  style: "https://demotiles.maplibre.org/style.json",
154
151
  center: [0, 0],
155
152
  zoom: 1,
156
153
  minPitch: 0,
157
154
  maxPitch: 0
158
- }));
155
+ }, (opts === null || opts === void 0 ? void 0 : opts.mapOptions) || {}));
159
156
 
160
157
  // `stagePadding: 0` is mandatory, so the bbox of the map & Sigma is the same.
161
158
  sigma.setSetting("stagePadding", 0);
@@ -211,13 +208,18 @@ function bindMaplibreLayer(sigma, opts) {
211
208
 
212
209
  // Clean up function to remove everything
213
210
  function clean() {
214
- map.off("moveend", fnSyncSigmaWithMap);
215
- map.remove();
216
- mapContainer.remove();
217
- sigma.off("afterRender", fnSyncMapWithSigma);
218
- sigma.off("resize", fnOnResize);
219
- sigma.setSetting("stagePadding", DEFAULT_SETTINGS.stagePadding);
220
- sigma.setSetting("enableCameraRotation", true);
211
+ if (!isKilled) {
212
+ isKilled = true;
213
+ map.off("moveend", fnSyncSigmaWithMap);
214
+ map.remove();
215
+ mapContainer.remove();
216
+ sigma.off("afterRender", fnSyncMapWithSigma);
217
+ sigma.off("resize", fnOnResize);
218
+
219
+ // Reset settings
220
+ sigma.setSetting("stagePadding", prevSigmaSettings.stagePadding);
221
+ sigma.setSetting("enableCameraRotation", prevSigmaSettings.enableCameraRotation);
222
+ }
221
223
  }
222
224
 
223
225
  // Update the sigma graph for geospatial coords
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigma/layer-maplibre",
3
- "version": "3.0.0-beta.3",
3
+ "version": "3.0.0-beta.5",
4
4
  "description": "A plugin to set a geographical map in background",
5
5
  "main": "dist/sigma-layer-maplibre.cjs.js",
6
6
  "module": "dist/sigma-layer-maplibre.esm.js",
@@ -13,7 +13,8 @@
13
13
  "bugs": "http://github.com/jacomyal/sigma.js/issues",
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "http://github.com/jacomyal/sigma.js.git"
16
+ "url": "http://github.com/jacomyal/sigma.js.git",
17
+ "directory": "packages/layer-maplibre"
17
18
  },
18
19
  "keywords": [
19
20
  "graph",
@@ -44,5 +45,5 @@
44
45
  },
45
46
  "./package.json": "./package.json"
46
47
  },
47
- "gitHead": "8f825b6250d8f22f0d44b911694b64aa080ac128"
48
+ "gitHead": "1e35ff6593ed8b566634bd41009fe0a9a0a64e1a"
48
49
  }