@yappkit/front-module-map 0.1.6 → 0.1.8

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