@yappkit/front-module-map 0.1.5 → 0.1.7

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.
@@ -50,11 +50,14 @@ class N {
50
50
  return;
51
51
  }
52
52
  this.watching.sources = !0;
53
- const t = d(() => (e.value || []).map((s) => {
54
- const { data: r, ...o } = s;
55
- return s.propsId = JSON.stringify(o), s;
56
- }), async (s, r) => {
57
- const o = r || [], n = s || [], i = n.filter((c, u) => {
53
+ const t = d(() => (e.value || []).map((r) => {
54
+ if (!r.propsId) {
55
+ const { data: s, ...o } = r;
56
+ r.propsId = JSON.stringify(o);
57
+ }
58
+ return r;
59
+ }), async (r, s) => {
60
+ const o = s || [], n = r || [], i = n.filter((c, u) => {
58
61
  var m;
59
62
  return c !== o[u] && c.propsId === ((m = o[u]) == null ? void 0 : m.propsId);
60
63
  }), p = n.filter((c, u) => c !== o[u] && !i.find((m) => m.id === c.id)), l = o.filter((c, u) => c !== n[u] && !i.find((m) => m.id === c.id));
@@ -81,8 +84,8 @@ class N {
81
84
  return;
82
85
  }
83
86
  this.watching.layers = !0;
84
- const t = d(e, async (s, r) => {
85
- const o = r || [], n = s || [], i = n.filter((l, c) => l !== o[c]), p = o.filter((l, c) => l !== n[c]);
87
+ const t = d(e, async (r, s) => {
88
+ const o = s || [], n = r || [], i = n.filter((l, c) => l !== o[c]), p = o.filter((l, c) => l !== n[c]);
86
89
  for (const l of p)
87
90
  this.map.removeLayer(l.id), this.map.getSource(l.id) && this.map.removeSource(l.id);
88
91
  await O();
@@ -110,12 +113,12 @@ class A {
110
113
  get Map() {
111
114
  return w(
112
115
  (e, { emit: a, slots: t }) => {
113
- const s = f(null), { options: r, layers: o, sources: n } = y(e), i = v(null);
114
- return g("mapboxMap", i), this.createMap(s, r.value).then((p) => {
115
- i.value = p, d(r, () => {
116
+ const r = f(null), { options: s, layers: o, sources: n } = y(e), i = v(null);
117
+ return g("mapboxMap", i), this.createMap(r, s.value).then((p) => {
118
+ i.value = p, d(s, () => {
116
119
  console.error("Cannot update options (missing function similar to deckglMap.setProps()). Use SDK dedicated functions instead");
117
- }, { once: !0 }), p.watchSources(n, r.value.watchSourcesOptions), p.watchLayers(o, r.value.watchLayersOptions), a("loaded", p);
118
- }), () => M("div", { ref: s }, i.value ? t : []);
120
+ }, { once: !0 }), p.watchSources(n, s.value.watchSourcesOptions), p.watchLayers(o, s.value.watchLayersOptions), a("loaded", p);
121
+ }), () => M("div", { ref: r }, i.value ? t : []);
119
122
  },
120
123
  {
121
124
  props: {
@@ -139,11 +142,11 @@ class A {
139
142
  get DeckGLOverlay() {
140
143
  return w(
141
144
  (e, { emit: a, slots: t }) => {
142
- const { options: s, layers: r } = y(e), o = L("mapboxMap");
145
+ const { options: r, layers: s } = y(e), o = L("mapboxMap");
143
146
  if (!o || !o.value)
144
147
  throw new Error("map should exist");
145
- return o.value.setDeckGLOverlay(s.value).then((n) => {
146
- n.watchOptions(s, s.value.watchOptionsOptions), n.watchLayers(r, s.value.watchLayersOptions), a("loaded", n);
148
+ return o.value.setDeckGLOverlay(r.value).then((n) => {
149
+ n.watchOptions(r, r.value.watchOptionsOptions), n.watchLayers(s, r.value.watchLayersOptions), a("loaded", n);
147
150
  }), () => {
148
151
  };
149
152
  },
@@ -187,11 +190,11 @@ class A {
187
190
  };
188
191
  }
189
192
  async loadMapboxSDK({ services: e = [] } = {}) {
190
- const t = (await import("@mapbox/mapbox-sdk")).default({ accessToken: this.apiKey }), s = [.../* @__PURE__ */ new Set([...this.services, ...e])];
191
- this.services = s;
192
- const r = await Promise.all(this.services.map((o) => this.sdk[o] || this.servicesLoader[o]().then((n) => n.default(t))));
193
+ const t = (await import("@mapbox/mapbox-sdk")).default({ accessToken: this.apiKey }), r = [.../* @__PURE__ */ new Set([...this.services, ...e])];
194
+ this.services = r;
195
+ const s = await Promise.all(this.services.map((o) => this.sdk[o] || this.servicesLoader[o]().then((n) => n.default(t))));
193
196
  for (const [o, n] of this.services.entries())
194
- this.sdk[n] = r[o];
197
+ this.sdk[n] = s[o];
195
198
  }
196
199
  async getSDK(e) {
197
200
  let a = {};
@@ -203,31 +206,31 @@ class A {
203
206
  return this.sdk;
204
207
  }
205
208
  async createMap(e, a = {}) {
206
- const t = new N(), s = () => {
207
- for (const r of t.unwatchFn)
208
- r();
209
+ const t = new N(), r = () => {
210
+ for (const s of t.unwatchFn)
211
+ s();
209
212
  t.unwatchFn = [], t.map && (t.map.remove(), t.map = null);
210
213
  };
211
- return new Promise((r, o) => {
214
+ return new Promise((s, o) => {
212
215
  b(async () => {
213
216
  await this.loadMapbox();
214
217
  const n = () => {
215
218
  if (!e.value)
216
219
  throw new Error("Missing HTML element");
217
220
  const i = d(e, () => {
218
- e.value || (s(), i());
221
+ e.value || (r(), i());
219
222
  });
220
223
  t.map = new this.mapboxgl.Map({
221
224
  container: e.value,
222
225
  accessToken: this.apiKey,
223
226
  ...a
224
227
  }), t.map.on("load", () => {
225
- r(t);
228
+ s(t);
226
229
  });
227
230
  };
228
231
  a.onMounted ? a.onMounted(n) : n();
229
232
  }), k(() => {
230
- s();
233
+ r();
231
234
  });
232
235
  });
233
236
  }
@@ -287,15 +290,15 @@ class I {
287
290
  }
288
291
  _getSetters(e) {
289
292
  const a = [], t = { ...Object.getOwnPropertyDescriptors(Object.getPrototypeOf(e)) };
290
- for (const [s, r] of Object.entries(t))
291
- r.enumerable && a.push(s);
293
+ for (const [r, s] of Object.entries(t))
294
+ s.enumerable && a.push(r);
292
295
  return a;
293
296
  }
294
297
  _getOptions(e) {
295
298
  const a = {}, t = this._getSetters(e);
296
- for (const s of t) {
297
- let r = e[s];
298
- e[s] instanceof Object && (r = this._getOptions(e[s])), a[s] = r;
299
+ for (const r of t) {
300
+ let s = e[r];
301
+ e[r] instanceof Object && (s = this._getOptions(e[r])), a[r] = s;
299
302
  }
300
303
  return a;
301
304
  }
@@ -320,18 +323,18 @@ class I {
320
323
  }
321
324
  this.watching.options = !0;
322
325
  let t = {};
323
- const s = d(e, async () => {
326
+ const r = d(e, async () => {
324
327
  await O();
325
- const r = x(e.value);
326
- for (const [o, n] of Object.entries(r))
328
+ const s = x(e.value);
329
+ for (const [o, n] of Object.entries(s))
327
330
  JSON.stringify(n) !== JSON.stringify(t[o]) && (this.map[o] = n);
328
- t = structuredClone(r);
331
+ t = structuredClone(s);
329
332
  }, {
330
333
  immediate: !0,
331
334
  deep: !0,
332
335
  ...a
333
336
  });
334
- this.unwatchFn.push(s);
337
+ this.unwatchFn.push(r);
335
338
  }
336
339
  watchLayers(e, a = {}) {
337
340
  if (!this.map)
@@ -341,8 +344,8 @@ class I {
341
344
  return;
342
345
  }
343
346
  this.watching.layers = !0;
344
- const t = d(e, async (s, r) => {
345
- const o = r || [], n = s || [], i = n.filter((l, c) => l !== o[c]), p = o.filter((l, c) => l !== n[c]);
347
+ const t = d(e, async (r, s) => {
348
+ const o = s || [], n = r || [], i = n.filter((l, c) => l !== o[c]), p = o.filter((l, c) => l !== n[c]);
346
349
  await O();
347
350
  for (const l of p)
348
351
  this.map.children.namedItem(l.id).remove();
@@ -364,12 +367,12 @@ class S {
364
367
  get Map() {
365
368
  return w(
366
369
  (e, { emit: a, slots: t }) => {
367
- const s = f(null), { options: r } = y(e), o = v(null);
368
- return g("googleMapsMap", o), this.createMap(s, r.value).then((n) => {
369
- o.value = n, d(r, () => {
370
+ const r = f(null), { options: s } = y(e), o = v(null);
371
+ return g("googleMapsMap", o), this.createMap(r, s.value).then((n) => {
372
+ o.value = n, d(s, () => {
370
373
  console.error("Cannot update options (missing function similar to deckglMap.setProps()). Use SDK dedicated functions instead");
371
374
  }, { once: !0 }), a("loaded", n);
372
- }), () => M("div", { ref: s }, o.value ? t : []);
375
+ }), () => M("div", { ref: r }, o.value ? t : []);
373
376
  },
374
377
  {
375
378
  props: {
@@ -384,11 +387,11 @@ class S {
384
387
  }
385
388
  get Map3D() {
386
389
  return w(
387
- (e, { emit: a, attrs: t, slots: s }) => {
388
- const r = f(null), { options: o, layers: n } = y(e), i = v(null);
389
- return g("googleMapsMap3D", i), this.createMap3D(r, o.value).then((p) => {
390
+ (e, { emit: a, attrs: t, slots: r }) => {
391
+ const s = f(null), { options: o, layers: n } = y(e), i = v(null);
392
+ return g("googleMapsMap3D", i), this.createMap3D(s, o.value).then((p) => {
390
393
  i.value = p, p.watchOptions(o, o.value.watchOptionsOptions), p.watchLayers(n, o.value.watchLayersOptions), a("loaded", p);
391
- }), () => M("div", { ref: r }, i.value ? s : []);
394
+ }), () => M("div", { ref: s }, i.value ? r : []);
392
395
  },
393
396
  {
394
397
  props: {
@@ -408,11 +411,11 @@ class S {
408
411
  get DeckGLOverlay() {
409
412
  return w(
410
413
  (e, { emit: a, slots: t }) => {
411
- const { options: s, layers: r } = y(e), o = L("googleMapsMap");
414
+ const { options: r, layers: s } = y(e), o = L("googleMapsMap");
412
415
  if (!o || !o.value)
413
416
  throw new Error("map should exist");
414
- return o.value.setDeckGLOverlay(s.value).then((n) => {
415
- n.watchOptions(s, s.value.watchOptionsOptions), n.watchLayers(r, s.value.watchLayersOptions), a("loaded", n);
417
+ return o.value.setDeckGLOverlay(r.value).then((n) => {
418
+ n.watchOptions(r, r.value.watchOptionsOptions), n.watchLayers(s, r.value.watchLayersOptions), a("loaded", n);
416
419
  }), () => {
417
420
  };
418
421
  },
@@ -434,15 +437,15 @@ class S {
434
437
  get DeckGL3DTileLayer() {
435
438
  return w(
436
439
  (e, { emit: a, slots: t }) => {
437
- const { options: s } = y(e), r = L("deckGLPrependLayers");
438
- if (!r || !r.value)
440
+ const { options: r } = y(e), s = L("deckGLPrependLayers");
441
+ if (!s || !s.value)
439
442
  throw new Error("deckGLPrependLayers should exist");
440
443
  const o = f("");
441
- this.createDeckGL3DTileLayer(o, s.value).then((i) => {
442
- d(s, () => {
444
+ this.createDeckGL3DTileLayer(o, r.value).then((i) => {
445
+ d(r, () => {
443
446
  console.error("Cannot update options on DeckGL layer. Replace layer instead");
444
- }, { once: !0 }), r.value = [
445
- ...r.value,
447
+ }, { once: !0 }), s.value = [
448
+ ...s.value,
446
449
  i
447
450
  ];
448
451
  });
@@ -464,14 +467,14 @@ class S {
464
467
  }
465
468
  async loadGoogleMapsSDK({ libraries: e = [] } = {}) {
466
469
  const { Loader: a } = await import("@googlemaps/js-api-loader"), t = [.../* @__PURE__ */ new Set([...this.libraries, ...e])];
467
- this.libraries.length === t.length && this.libraries.every((r) => t.includes(r)) || console.error("GoogleMaps Loader does not allow loading one library after the other. Set libraries option on a single googleMaps config"), this.libraries = t, this.loader = new a({
470
+ this.libraries.length === t.length && this.libraries.every((s) => t.includes(s)) || console.error("GoogleMaps Loader does not allow loading one library after the other. Set libraries option on a single googleMaps config"), this.libraries = t, this.loader = new a({
468
471
  apiKey: this.apiKey,
469
472
  version: this.version,
470
473
  libraries: this.libraries
471
474
  });
472
- const s = await Promise.all(this.libraries.map((r) => this.sdk[r] || this.loader.importLibrary(r)));
473
- for (const [r, o] of this.libraries.entries())
474
- this.sdk[o] = s[r];
475
+ const r = await Promise.all(this.libraries.map((s) => this.sdk[s] || this.loader.importLibrary(s)));
476
+ for (const [s, o] of this.libraries.entries())
477
+ this.sdk[o] = r[s];
475
478
  }
476
479
  async getSDK(e) {
477
480
  let a = {};
@@ -483,52 +486,52 @@ class S {
483
486
  return this.sdk;
484
487
  }
485
488
  async createMap(e, a = {}) {
486
- const t = new V(), s = () => {
487
- for (const r of t.unwatchFn)
488
- r();
489
+ const t = new V(), r = () => {
490
+ for (const s of t.unwatchFn)
491
+ s();
489
492
  t.unwatchFn = [], t.map && (t.map = null);
490
493
  };
491
- return new Promise((r, o) => {
494
+ return new Promise((s, o) => {
492
495
  b(async () => {
493
496
  await this.getSDK("maps");
494
497
  const n = () => {
495
498
  if (!e.value)
496
499
  throw new Error("Missing HTML element");
497
500
  const i = d(e, () => {
498
- e.value || (s(), i());
501
+ e.value || (r(), i());
499
502
  });
500
503
  t.map = new this.sdk.maps.Map(e.value, {
501
504
  ...a
502
- }), r(t);
505
+ }), s(t);
503
506
  };
504
507
  a.onMounted ? a.onMounted(n) : n();
505
508
  }), k(() => {
506
- s();
509
+ r();
507
510
  });
508
511
  });
509
512
  }
510
513
  async createMap3D(e, a = {}) {
511
- const t = new I(), s = () => {
512
- for (const r of t.unwatchFn)
513
- r();
514
+ const t = new I(), r = () => {
515
+ for (const s of t.unwatchFn)
516
+ s();
514
517
  t.unwatchFn = [], t.map && (t.map = null);
515
518
  };
516
- return new Promise((r, o) => {
519
+ return new Promise((s, o) => {
517
520
  b(async () => {
518
521
  await this.getSDK("maps3d");
519
522
  const n = () => {
520
523
  if (!e.value)
521
524
  throw new Error("Missing HTML element");
522
525
  const i = d(e, () => {
523
- e.value || (s(), i());
526
+ e.value || (r(), i());
524
527
  });
525
528
  t.map = new this.sdk.maps3d.Map3DElement({
526
529
  ...a
527
- }), e.value.appendChild(t.map), r(t);
530
+ }), e.value.appendChild(t.map), s(t);
528
531
  };
529
532
  a.onMounted ? a.onMounted(n) : n();
530
533
  }), k(() => {
531
- s();
534
+ r();
532
535
  });
533
536
  });
534
537
  }
@@ -548,12 +551,12 @@ class S {
548
551
  }
549
552
  },
550
553
  onTilesetLoad: (t) => {
551
- e && (t.options.onTraversalComplete = (s) => {
552
- const r = /* @__PURE__ */ new Set();
553
- return s.forEach((o) => {
554
+ e && (t.options.onTraversalComplete = (r) => {
555
+ const s = /* @__PURE__ */ new Set();
556
+ return r.forEach((o) => {
554
557
  const { copyright: n } = o.content.gltf.asset;
555
- n.split(";").forEach(r.add, r), e.value = [...r].join("; ");
556
- }), s;
558
+ n.split(";").forEach(s.add, s), e.value = [...s].join("; ");
559
+ }), r;
557
560
  });
558
561
  },
559
562
  operation: "terrain+draw",
@@ -605,8 +608,8 @@ class F {
605
608
  }
606
609
  get Map() {
607
610
  return w(
608
- (e, { emit: a, attrs: t, slots: s }) => {
609
- const r = f(null), { options: o, layers: n } = y(e), i = v(null);
611
+ (e, { emit: a, attrs: t, slots: r }) => {
612
+ const s = f(null), { options: o, layers: n } = y(e), i = v(null);
610
613
  g("deckGLMap", i);
611
614
  const p = v([]);
612
615
  g("deckGLPrependLayers", p);
@@ -614,11 +617,11 @@ class F {
614
617
  ...p.value,
615
618
  ...n.value
616
619
  ]);
617
- this.createMap(r, o.value).then((u) => {
620
+ this.createMap(s, o.value).then((u) => {
618
621
  i.value = u, u.watchOptions(o, o.value.watchOptionsOptions), u.watchLayers(l, o.value.watchLayersOptions), a("loaded", u);
619
622
  });
620
623
  const c = f([]);
621
- return g("deckGLAppendVNodeFn", c), () => [M("div", { ...t, ref: r }, i.value ? s : []), c.value.map((u) => u())];
624
+ return g("deckGLAppendVNodeFn", c), () => [M("div", { ...t, ref: s }, i.value ? r : []), c.value.map((u) => u())];
622
625
  },
623
626
  {
624
627
  props: {
@@ -642,28 +645,28 @@ class F {
642
645
  }
643
646
  }
644
647
  async createMap(e, a = {}) {
645
- const t = new _(), s = () => {
646
- for (const r of t.unwatchFn)
647
- r();
648
+ const t = new _(), r = () => {
649
+ for (const s of t.unwatchFn)
650
+ s();
648
651
  t.unwatchFn = [], t.map && (t.map.finalize(), t.map = null);
649
652
  };
650
- return new Promise((r, o) => {
653
+ return new Promise((s, o) => {
651
654
  b(async () => {
652
655
  await this.loadDeckGL();
653
656
  const n = () => {
654
657
  if (!e.value)
655
658
  throw new Error("Missing HTML element");
656
659
  const i = d(e, () => {
657
- e.value || (s(), i());
660
+ e.value || (r(), i());
658
661
  });
659
662
  t.deckgl = this.deckgl, t.map = new this.deckgl.Deck({
660
663
  parent: e.value,
661
664
  ...a
662
- }), r(t);
665
+ }), s(t);
663
666
  };
664
667
  a.onMounted ? a.onMounted(n) : n();
665
668
  }), k(() => {
666
- s();
669
+ r();
667
670
  });
668
671
  });
669
672
  }
@@ -676,16 +679,16 @@ function D(h) {
676
679
  });
677
680
  }
678
681
  function z({ origin: h, destination: e, step: a = 100 }) {
679
- const t = K([h, e]), s = P(t), r = [];
680
- for (let o = 0; o < s; o += s / a) {
682
+ const t = K([h, e]), r = P(t), s = [];
683
+ for (let o = 0; o < r; o += r / a) {
681
684
  const n = j(t, o);
682
- r.push(n.geometry.coordinates);
685
+ s.push(n.geometry.coordinates);
683
686
  }
684
- return r.push(e), t.geometry.coordinates = D(r), t;
687
+ return s.push(e), t.geometry.coordinates = D(s), t;
685
688
  }
686
689
  async function H({ origin: h, destination: e, includeBoundaries: a = !1 }) {
687
- const t = (await import("./searoute.js")).default, s = t(G(h), G(e));
688
- return a && (s.geometry.coordinates.unshift(h), s.geometry.coordinates.push(e)), s.geometry.coordinates = D(s.geometry.coordinates), s;
690
+ const t = (await import("./searoute.js")).default, r = t(G(h), G(e));
691
+ return a && (r.geometry.coordinates.unshift(h), r.geometry.coordinates.push(e)), r.geometry.coordinates = D(r.geometry.coordinates), r;
689
692
  }
690
693
  const R = {
691
694
  getAirRoute: z,
@@ -702,15 +705,19 @@ class q {
702
705
  constructor(e = {}) {
703
706
  this.options = { ...e };
704
707
  }
705
- install(e) {
706
- const a = {};
707
- for (const [t, s] of Object.entries(e.config.maps || {})) {
708
+ install(e, a) {
709
+ const t = {};
710
+ for (const [r, 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 = U[s.type];
711
- r ? a[t] = new r(s) : console.warn(`Map provider: ${s.type} is not supported`);
713
+ const o = U[s.type];
714
+ o ? t[r] = new o(s) : console.warn(`Map provider: ${s.type} is not supported`);
712
715
  }
713
- e.maps = a, e.map = a, this.yAppKit = e;
716
+ return e.maps = t, e.map = t, this.yAppKit = e, {
717
+ // onBeforeSetup,
718
+ // onAfterSetup,
719
+ // options
720
+ };
714
721
  }
715
722
  }
716
723
  const W = (h) => new q(h);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yappkit/front-module-map",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
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.35",
37
- "@deck.gl/mapbox": "^8.9.35",
38
- "@googlemaps/js-api-loader": "^1.16.6",
39
- "@mapbox/mapbox-sdk": "^0.15.3",
40
- "@turf/turf": "^6.5.0",
41
- "deck.gl": "^8.9.35",
36
+ "@deck.gl/google-maps": "^9.0.36",
37
+ "@deck.gl/mapbox": "^9.0.36",
38
+ "@googlemaps/js-api-loader": "^1.16.8",
39
+ "@mapbox/mapbox-sdk": "^0.16.1",
40
+ "@turf/turf": "^7.1.0",
41
+ "deck.gl": "^9.0.36",
42
42
  "geojson-path-finder": "2.0.2",
43
- "maplibre-gl": "^4.1.0",
44
- "vue": "^3.4.21"
43
+ "maplibre-gl": "^4.7.1",
44
+ "vue": "^3.5.13"
45
45
  }
46
46
  }