@yappkit/front-module-map 0.1.4 → 0.1.6

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.
@@ -244,7 +244,7 @@ class F {
244
244
  let s = {};
245
245
  if (typeof e == "string" ? s.libraries = [e] : s = { ...e }, await this.loadGoogleMapsSDK(s), typeof e == "string") {
246
246
  if (!this.sdk[e] || !Object.keys(this.sdk[e]).length)
247
- throw new Error(`${e} library is not loaded${e === "maps3d" ? ". Missing version: 'alpha'?" : ""}`);
247
+ throw new Error(`${e} library is not loaded${e === "maps3d" ? ". Missing version: 'alpha' or apiKey not authorized?" : ""}`);
248
248
  return this.sdk[e];
249
249
  }
250
250
  return this.sdk;
@@ -49,14 +49,17 @@ class k {
49
49
  return;
50
50
  }
51
51
  this.watching.sources = !0;
52
- const t = d(() => (e.value || []).map((o) => {
53
- const { data: n, ...s } = o;
54
- return o.propsId = JSON.stringify(s), o;
55
- }), async (o, n) => {
56
- const s = n || [], i = o || [], c = i.filter((r, h) => {
52
+ const t = d(() => (e.value || []).map((s) => {
53
+ if (!s.propsId) {
54
+ const { data: n, ...o } = s;
55
+ s.propsId = JSON.stringify(o);
56
+ }
57
+ return s;
58
+ }), async (s, n) => {
59
+ const o = n || [], i = s || [], c = i.filter((r, h) => {
57
60
  var u;
58
- return r !== s[h] && r.propsId === ((u = s[h]) == null ? void 0 : u.propsId);
59
- }), p = i.filter((r, h) => r !== s[h] && !c.find((u) => u.id === r.id)), l = s.filter((r, h) => r !== i[h] && !c.find((u) => u.id === r.id));
61
+ return r !== o[h] && r.propsId === ((u = o[h]) == null ? void 0 : u.propsId);
62
+ }), p = i.filter((r, h) => r !== o[h] && !c.find((u) => u.id === r.id)), l = o.filter((r, h) => r !== i[h] && !c.find((u) => u.id === r.id));
60
63
  for (const r of c)
61
64
  this.map.getSource(r.id).setData(r.data);
62
65
  await f();
@@ -80,8 +83,8 @@ class k {
80
83
  return;
81
84
  }
82
85
  this.watching.layers = !0;
83
- const t = d(e, async (o, n) => {
84
- const s = n || [], i = o || [], c = i.filter((l, r) => l !== s[r]), p = s.filter((l, r) => l !== i[r]);
86
+ const t = d(e, async (s, n) => {
87
+ const o = n || [], i = s || [], c = i.filter((l, r) => l !== o[r]), p = o.filter((l, r) => l !== i[r]);
85
88
  for (const l of p)
86
89
  this.map.removeLayer(l.id), this.map.getSource(l.id) && this.map.removeSource(l.id);
87
90
  await f();
@@ -109,12 +112,12 @@ class K {
109
112
  get Map() {
110
113
  return m(
111
114
  (e, { emit: a, slots: t }) => {
112
- const o = v(null), { options: n, layers: s, sources: i } = y(e), c = g(null);
113
- return b("mapboxMap", c), this.createMap(o, n.value).then((p) => {
115
+ const s = v(null), { options: n, layers: o, sources: i } = y(e), c = g(null);
116
+ return b("mapboxMap", c), this.createMap(s, n.value).then((p) => {
114
117
  c.value = p, d(n, () => {
115
118
  console.error("Cannot update options (missing function similar to deckglMap.setProps()). Use SDK dedicated functions instead");
116
- }, { once: !0 }), p.watchSources(i, n.value.watchSourcesOptions), p.watchLayers(s, n.value.watchLayersOptions), a("loaded", p);
117
- }), () => M("div", { ref: o }, c.value ? t : []);
119
+ }, { once: !0 }), p.watchSources(i, n.value.watchSourcesOptions), p.watchLayers(o, n.value.watchLayersOptions), a("loaded", p);
120
+ }), () => M("div", { ref: s }, c.value ? t : []);
118
121
  },
119
122
  {
120
123
  props: {
@@ -138,11 +141,11 @@ class K {
138
141
  get DeckGLOverlay() {
139
142
  return m(
140
143
  (e, { emit: a, slots: t }) => {
141
- const { options: o, layers: n } = y(e), s = x("mapboxMap");
142
- if (!s || !s.value)
144
+ const { options: s, layers: n } = y(e), o = x("mapboxMap");
145
+ if (!o || !o.value)
143
146
  throw new Error("map should exist");
144
- return s.value.setDeckGLOverlay(o.value).then((i) => {
145
- i.watchOptions(o, o.value.watchOptionsOptions), i.watchLayers(n, o.value.watchLayersOptions), a("loaded", i);
147
+ return o.value.setDeckGLOverlay(s.value).then((i) => {
148
+ i.watchOptions(s, s.value.watchOptionsOptions), i.watchLayers(n, s.value.watchLayersOptions), a("loaded", i);
146
149
  }), () => {
147
150
  };
148
151
  },
@@ -186,11 +189,11 @@ class K {
186
189
  };
187
190
  }
188
191
  async loadMapboxSDK({ services: e = [] } = {}) {
189
- const t = (await import("@mapbox/mapbox-sdk")).default({ accessToken: this.apiKey }), o = [.../* @__PURE__ */ new Set([...this.services, ...e])];
190
- this.services = o;
191
- const n = await Promise.all(this.services.map((s) => this.sdk[s] || this.servicesLoader[s]().then((i) => i.default(t))));
192
- for (const [s, i] of this.services.entries())
193
- this.sdk[i] = n[s];
192
+ const t = (await import("@mapbox/mapbox-sdk")).default({ accessToken: this.apiKey }), s = [.../* @__PURE__ */ new Set([...this.services, ...e])];
193
+ this.services = s;
194
+ const n = await Promise.all(this.services.map((o) => this.sdk[o] || this.servicesLoader[o]().then((i) => i.default(t))));
195
+ for (const [o, i] of this.services.entries())
196
+ this.sdk[i] = n[o];
194
197
  }
195
198
  async getSDK(e) {
196
199
  let a = {};
@@ -202,19 +205,19 @@ class K {
202
205
  return this.sdk;
203
206
  }
204
207
  async createMap(e, a = {}) {
205
- const t = new k(), o = () => {
208
+ const t = new k(), s = () => {
206
209
  for (const n of t.unwatchFn)
207
210
  n();
208
211
  t.unwatchFn = [], t.map && (t.map.remove(), t.map = null);
209
212
  };
210
- return new Promise((n, s) => {
213
+ return new Promise((n, o) => {
211
214
  S(async () => {
212
215
  await this.loadMapbox();
213
216
  const i = () => {
214
217
  if (!e.value)
215
218
  throw new Error("Missing HTML element");
216
219
  const c = d(e, () => {
217
- e.value || (o(), c());
220
+ e.value || (s(), c());
218
221
  });
219
222
  t.map = new this.mapboxgl.Map({
220
223
  container: e.value,
@@ -226,7 +229,7 @@ class K {
226
229
  };
227
230
  a.onMounted ? a.onMounted(i) : i();
228
231
  }), L(() => {
229
- o();
232
+ s();
230
233
  });
231
234
  });
232
235
  }
@@ -49,14 +49,17 @@ class k {
49
49
  return;
50
50
  }
51
51
  this.watching.sources = !0;
52
- const t = d(() => (e.value || []).map((o) => {
53
- const { data: n, ...s } = o;
54
- return o.propsId = JSON.stringify(s), o;
55
- }), async (o, n) => {
56
- const s = n || [], i = o || [], c = i.filter((r, h) => {
52
+ const t = d(() => (e.value || []).map((s) => {
53
+ if (!s.propsId) {
54
+ const { data: n, ...o } = s;
55
+ s.propsId = JSON.stringify(o);
56
+ }
57
+ return s;
58
+ }), async (s, n) => {
59
+ const o = n || [], i = s || [], c = i.filter((r, h) => {
57
60
  var u;
58
- return r !== s[h] && r.propsId === ((u = s[h]) == null ? void 0 : u.propsId);
59
- }), p = i.filter((r, h) => r !== s[h] && !c.find((u) => u.id === r.id)), l = s.filter((r, h) => r !== i[h] && !c.find((u) => u.id === r.id));
61
+ return r !== o[h] && r.propsId === ((u = o[h]) == null ? void 0 : u.propsId);
62
+ }), p = i.filter((r, h) => r !== o[h] && !c.find((u) => u.id === r.id)), l = o.filter((r, h) => r !== i[h] && !c.find((u) => u.id === r.id));
60
63
  for (const r of c)
61
64
  this.map.getSource(r.id).setData(r.data);
62
65
  await f();
@@ -80,8 +83,8 @@ class k {
80
83
  return;
81
84
  }
82
85
  this.watching.layers = !0;
83
- const t = d(e, async (o, n) => {
84
- const s = n || [], i = o || [], c = i.filter((l, r) => l !== s[r]), p = s.filter((l, r) => l !== i[r]);
86
+ const t = d(e, async (s, n) => {
87
+ const o = n || [], i = s || [], c = i.filter((l, r) => l !== o[r]), p = o.filter((l, r) => l !== i[r]);
85
88
  for (const l of p)
86
89
  this.map.removeLayer(l.id), this.map.getSource(l.id) && this.map.removeSource(l.id);
87
90
  await f();
@@ -109,12 +112,12 @@ class D {
109
112
  get Map() {
110
113
  return m(
111
114
  (e, { emit: a, slots: t }) => {
112
- const o = v(null), { options: n, layers: s, sources: i } = y(e), c = b(null);
113
- return g("mapboxMap", c), this.createMap(o, n.value).then((p) => {
115
+ const s = v(null), { options: n, layers: o, sources: i } = y(e), c = b(null);
116
+ return g("mapboxMap", c), this.createMap(s, n.value).then((p) => {
114
117
  c.value = p, d(n, () => {
115
118
  console.error("Cannot update options (missing function similar to deckglMap.setProps()). Use SDK dedicated functions instead");
116
- }, { once: !0 }), p.watchSources(i, n.value.watchSourcesOptions), p.watchLayers(s, n.value.watchLayersOptions), a("loaded", p);
117
- }), () => x("div", { ref: o }, c.value ? t : []);
119
+ }, { once: !0 }), p.watchSources(i, n.value.watchSourcesOptions), p.watchLayers(o, n.value.watchLayersOptions), a("loaded", p);
120
+ }), () => x("div", { ref: s }, c.value ? t : []);
118
121
  },
119
122
  {
120
123
  props: {
@@ -138,11 +141,11 @@ class D {
138
141
  get DeckGLOverlay() {
139
142
  return m(
140
143
  (e, { emit: a, slots: t }) => {
141
- const { options: o, layers: n } = y(e), s = M("mapboxMap");
142
- if (!s || !s.value)
144
+ const { options: s, layers: n } = y(e), o = M("mapboxMap");
145
+ if (!o || !o.value)
143
146
  throw new Error("map should exist");
144
- return s.value.setDeckGLOverlay(o.value).then((i) => {
145
- i.watchOptions(o, o.value.watchOptionsOptions), i.watchLayers(n, o.value.watchLayersOptions), a("loaded", i);
147
+ return o.value.setDeckGLOverlay(s.value).then((i) => {
148
+ i.watchOptions(s, s.value.watchOptionsOptions), i.watchLayers(n, s.value.watchLayersOptions), a("loaded", i);
146
149
  }), () => {
147
150
  };
148
151
  },
@@ -186,11 +189,11 @@ class D {
186
189
  };
187
190
  }
188
191
  async loadMapboxSDK({ services: e = [] } = {}) {
189
- const t = (await import("@mapbox/mapbox-sdk")).default({ accessToken: this.apiKey }), o = [.../* @__PURE__ */ new Set([...this.services, ...e])];
190
- this.services = o;
191
- const n = await Promise.all(this.services.map((s) => this.sdk[s] || this.servicesLoader[s]().then((i) => i.default(t))));
192
- for (const [s, i] of this.services.entries())
193
- this.sdk[i] = n[s];
192
+ const t = (await import("@mapbox/mapbox-sdk")).default({ accessToken: this.apiKey }), s = [.../* @__PURE__ */ new Set([...this.services, ...e])];
193
+ this.services = s;
194
+ const n = await Promise.all(this.services.map((o) => this.sdk[o] || this.servicesLoader[o]().then((i) => i.default(t))));
195
+ for (const [o, i] of this.services.entries())
196
+ this.sdk[i] = n[o];
194
197
  }
195
198
  async getSDK(e) {
196
199
  let a = {};
@@ -202,19 +205,19 @@ class D {
202
205
  return this.sdk;
203
206
  }
204
207
  async createMap(e, a = {}) {
205
- const t = new k(), o = () => {
208
+ const t = new k(), s = () => {
206
209
  for (const n of t.unwatchFn)
207
210
  n();
208
211
  t.unwatchFn = [], t.map && (t.map.remove(), t.map = null);
209
212
  };
210
- return new Promise((n, s) => {
213
+ return new Promise((n, o) => {
211
214
  S(async () => {
212
215
  await this.loadMapbox();
213
216
  const i = () => {
214
217
  if (!e.value)
215
218
  throw new Error("Missing HTML element");
216
219
  const c = d(e, () => {
217
- e.value || (o(), c());
220
+ e.value || (s(), c());
218
221
  });
219
222
  t.map = new this.mapboxgl.Map({
220
223
  container: e.value,
@@ -226,7 +229,7 @@ class D {
226
229
  };
227
230
  a.onMounted ? a.onMounted(i) : i();
228
231
  }), L(() => {
229
- o();
232
+ s();
230
233
  });
231
234
  });
232
235
  }
@@ -51,8 +51,11 @@ class N {
51
51
  }
52
52
  this.watching.sources = !0;
53
53
  const t = d(() => (e.value || []).map((s) => {
54
- const { data: r, ...o } = s;
55
- return s.propsId = JSON.stringify(o), s;
54
+ if (!s.propsId) {
55
+ const { data: r, ...o } = s;
56
+ s.propsId = JSON.stringify(o);
57
+ }
58
+ return s;
56
59
  }), async (s, r) => {
57
60
  const o = r || [], n = s || [], i = n.filter((c, u) => {
58
61
  var m;
@@ -477,7 +480,7 @@ class S {
477
480
  let a = {};
478
481
  if (typeof e == "string" ? a.libraries = [e] : a = { ...e }, await this.loadGoogleMapsSDK(a), typeof e == "string") {
479
482
  if (!this.sdk[e] || !Object.keys(this.sdk[e]).length)
480
- throw new Error(`${e} library is not loaded${e === "maps3d" ? ". Missing version: 'alpha'?" : ""}`);
483
+ throw new Error(`${e} library is not loaded${e === "maps3d" ? ". Missing version: 'alpha' or apiKey not authorized?" : ""}`);
481
484
  return this.sdk[e];
482
485
  }
483
486
  return this.sdk;
@@ -675,7 +678,7 @@ function D(h) {
675
678
  return t - e > 180 ? t += -360 : e - t > 180 ? t += 360 : t += 0, e = t, [t, a[1]];
676
679
  });
677
680
  }
678
- function H({ origin: h, destination: e, step: a = 100 }) {
681
+ function z({ origin: h, destination: e, step: a = 100 }) {
679
682
  const t = K([h, e]), s = P(t), r = [];
680
683
  for (let o = 0; o < s; o += s / a) {
681
684
  const n = j(t, o);
@@ -683,22 +686,22 @@ function H({ origin: h, destination: e, step: a = 100 }) {
683
686
  }
684
687
  return r.push(e), t.geometry.coordinates = D(r), t;
685
688
  }
686
- async function U({ origin: h, destination: e, includeBoundaries: a = !1 }) {
689
+ async function H({ origin: h, destination: e, includeBoundaries: a = !1 }) {
687
690
  const t = (await import("./searoute.js")).default, s = t(G(h), G(e));
688
691
  return a && (s.geometry.coordinates.unshift(h), s.geometry.coordinates.push(e)), s.geometry.coordinates = D(s.geometry.coordinates), s;
689
692
  }
690
693
  const R = {
691
- getAirRoute: H,
692
- getWaterRoute: U,
694
+ getAirRoute: z,
695
+ getWaterRoute: H,
693
696
  normalizeRoute: D
694
- }, q = {
697
+ }, U = {
695
698
  mapbox: A,
696
699
  google: S,
697
700
  "google-maps": S,
698
701
  deckgl: F,
699
702
  "deck-gl": F
700
703
  };
701
- class z {
704
+ class q {
702
705
  constructor(e = {}) {
703
706
  this.options = { ...e };
704
707
  }
@@ -707,16 +710,16 @@ class z {
707
710
  for (const [t, s] of Object.entries(e.config.maps || {})) {
708
711
  if (!s.type)
709
712
  throw new Error("Map type should be defined");
710
- const r = q[s.type];
713
+ const r = U[s.type];
711
714
  r ? a[t] = new r(s) : console.warn(`Map provider: ${s.type} is not supported`);
712
715
  }
713
716
  e.maps = a, e.map = a, this.yAppKit = e;
714
717
  }
715
718
  }
716
- const W = (h) => new z(h);
719
+ const W = (h) => new q(h);
717
720
  export {
718
- z as default,
721
+ q as default,
719
722
  W as loadMapModule,
720
- q as mapProviders,
723
+ U as mapProviders,
721
724
  R as utils
722
725
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yappkit/front-module-map",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "@yappkit/front module for map",
5
5
  "module": "./lib/yappkit-map.js",
6
6
  "main": "./lib/yappkit-map.js",
@@ -33,14 +33,14 @@
33
33
  },
34
34
  "dependencies": {},
35
35
  "peerDependencies": {
36
- "@deck.gl/google-maps": "^8.9.34",
37
- "@deck.gl/mapbox": "^8.9.34",
38
- "@googlemaps/js-api-loader": "^1.16.2",
36
+ "@deck.gl/google-maps": "^8.9.35",
37
+ "@deck.gl/mapbox": "^8.9.35",
38
+ "@googlemaps/js-api-loader": "^1.16.6",
39
39
  "@mapbox/mapbox-sdk": "^0.15.3",
40
40
  "@turf/turf": "^6.5.0",
41
- "deck.gl": "^8.9.34",
41
+ "deck.gl": "^8.9.35",
42
42
  "geojson-path-finder": "2.0.2",
43
- "maplibre-gl": "^4.0.0",
44
- "vue": "^3.4.18"
43
+ "maplibre-gl": "^4.1.0",
44
+ "vue": "^3.4.21"
45
45
  }
46
46
  }