@yappkit/front-module-map 0.1.1 → 0.1.3

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,17 +1,17 @@
1
- import { defineComponent as m, ref as f, toRefs as y, shallowRef as v, provide as b, h as g, inject as x, onMounted as M, onUnmounted as L, watch as p, nextTick as w } from "vue";
1
+ import { defineComponent as m, ref as f, toRefs as y, shallowRef as v, provide as b, h as g, inject as x, onMounted as M, onUnmounted as L, watch as d, nextTick as w } from "vue";
2
2
  class S {
3
3
  constructor() {
4
4
  this.overlay = null, this.watching = { layers: !1 };
5
5
  }
6
- watchLayers(e, s = {}) {
6
+ watchLayers(t, s = {}) {
7
7
  if (!this.overlay)
8
8
  throw new Error("overlay should be set");
9
9
  if (this.watching.layers) {
10
10
  console.warn("No need to call MapboxDeckGLOverlay.watchLayers(). layers are already being watched");
11
11
  return;
12
12
  }
13
- this.watching.layers = !0, p(e, () => {
14
- this.overlay.setProps({ layers: e.value });
13
+ this.watching.layers = !0, d(t, () => {
14
+ this.overlay.setProps({ layers: t.value });
15
15
  }, s);
16
16
  }
17
17
  }
@@ -19,62 +19,62 @@ class k {
19
19
  constructor() {
20
20
  this.map = null, this.watching = { sources: !1, layers: !1 };
21
21
  }
22
- watchSources(e, s = {}) {
22
+ watchSources(t, s = {}) {
23
23
  if (!this.map)
24
24
  throw new Error("map should be set");
25
25
  if (this.watching.sources) {
26
26
  console.warn("No need to call MapboxMap.watchSources(). sources are already being watched");
27
27
  return;
28
28
  }
29
- this.watching.sources = !0, p(e, (a, o) => {
30
- const r = [...o || []], i = [...a || []], n = i.map((t) => t.id), l = r.map((t) => t.id), c = i.filter((t) => !l.includes(t.id)), h = r.filter((t) => !n.includes(t.id));
31
- for (const t of h)
29
+ this.watching.sources = !0, d(t, (a, r) => {
30
+ const o = [...r || []], i = [...a || []], n = i.map((e) => e.id), l = o.map((e) => e.id), c = i.filter((e) => !l.includes(e.id)), p = o.filter((e) => !n.includes(e.id));
31
+ for (const e of p)
32
32
  w(() => {
33
- this.map.removeSource(t.id);
33
+ this.map.removeSource(e.id);
34
34
  });
35
- for (const t of c) {
36
- const u = { ...t };
37
- delete u.id, this.map.addSource(t.id, u);
35
+ for (const e of c) {
36
+ const u = { ...e };
37
+ delete u.id, this.map.addSource(e.id, u);
38
38
  }
39
39
  }, s);
40
40
  }
41
- watchLayers(e, s = {}) {
41
+ watchLayers(t, s = {}) {
42
42
  if (!this.map)
43
43
  throw new Error("map should be set");
44
44
  if (this.watching.layers) {
45
45
  console.warn("No need to call MapboxMap.watchLayers(). layers are already being watched");
46
46
  return;
47
47
  }
48
- this.watching.layers = !0, p(e, (a, o) => {
49
- const r = [...o || []], i = [...a || []], n = i.map((t) => t.id), l = r.map((t) => t.id), c = i.filter((t) => !l.includes(t.id)), h = r.filter((t) => !n.includes(t.id));
50
- for (const t of h)
51
- this.map.removeLayer(t.id);
52
- for (const t of c)
48
+ this.watching.layers = !0, d(t, (a, r) => {
49
+ const o = [...r || []], i = [...a || []], n = i.map((e) => e.id), l = o.map((e) => e.id), c = i.filter((e) => !l.includes(e.id)), p = o.filter((e) => !n.includes(e.id));
50
+ for (const e of p)
51
+ this.map.removeLayer(e.id);
52
+ for (const e of c)
53
53
  w(() => {
54
- this.map.addLayer(t);
54
+ this.map.addLayer(e);
55
55
  });
56
56
  }, s);
57
57
  }
58
- async setDeckGLOverlay(e = {}) {
58
+ async setDeckGLOverlay(t = {}) {
59
59
  if (!this.map)
60
60
  throw new Error("map should be set");
61
61
  const { MapboxOverlay: s } = await import("@deck.gl/mapbox"), a = new S();
62
- return a.overlay = new s(e), this.map.addControl(a.overlay), a;
62
+ return a.overlay = new s(t), this.map.addControl(a.overlay), a;
63
63
  }
64
64
  }
65
65
  class D {
66
- constructor(e) {
67
- if (this.apiKey = e.apiKey, !this.apiKey)
66
+ constructor(t) {
67
+ if (this.apiKey = t.apiKey, !this.apiKey)
68
68
  throw new Error("apiKey is required");
69
- this.services = e.services || [], this.sdk = {}, this.mapboxgl = null, this.services.length && this.loadMapboxSDK();
69
+ this.services = t.services || [], this.sdk = {}, this.mapboxgl = null, this.services.length && this.loadMapboxSDK();
70
70
  }
71
71
  get Map() {
72
72
  return m(
73
- (e, { emit: s, slots: a }) => {
74
- const o = f(null), { options: r, layers: i, sources: n } = y(e), l = v(null);
75
- return b("mapboxMap", l), this.createMap(o, r.value).then((c) => {
76
- l.value = c, c.watchSources(n, r.value.watchSourcesOptions || { immediate: !0 }), c.watchLayers(i, r.value.watchLayersOptions || { immediate: !0 }), s("loaded", c);
77
- }), () => g("div", { ref: o }, l.value ? a : []);
73
+ (t, { emit: s, slots: a }) => {
74
+ const r = f(null), { options: o, layers: i, sources: n } = y(t), l = v(null);
75
+ return b("mapboxMap", l), this.createMap(r, o.value).then((c) => {
76
+ l.value = c, c.watchSources(n, o.value.watchSourcesOptions || { immediate: !0 }), c.watchLayers(i, o.value.watchLayersOptions || { immediate: !0 }), s("loaded", c);
77
+ }), () => g("div", { ref: r }, l.value ? a : []);
78
78
  },
79
79
  {
80
80
  props: {
@@ -96,12 +96,12 @@ class D {
96
96
  }
97
97
  get DeckGLOverlay() {
98
98
  return m(
99
- (e, { emit: s, slots: a }) => {
100
- const { options: o, layers: r } = y(e), i = x("mapboxMap");
99
+ (t, { emit: s, slots: a }) => {
100
+ const { options: r, layers: o } = y(t), i = x("mapboxMap");
101
101
  if (!i || !i.value)
102
102
  throw new Error("map should exist");
103
- return i.value.setDeckGLOverlay(o.value).then((n) => {
104
- n.watchLayers(r, o.value.watchLayersOptions || { immediate: !0 }), s("loaded", n);
103
+ return i.value.setDeckGLOverlay(r.value).then((n) => {
104
+ n.watchLayers(o, r.value.watchLayersOptions || { immediate: !0 }), s("loaded", n);
105
105
  }), () => {
106
106
  };
107
107
  },
@@ -120,49 +120,49 @@ class D {
120
120
  );
121
121
  }
122
122
  async loadMapbox() {
123
- const e = await import("../mapbox-gl.js").then((s) => s.mapboxGl);
124
- this.mapboxgl = e;
123
+ const t = await import("../mapbox-gl.js").then((s) => s.mapboxGl);
124
+ this.mapboxgl = t;
125
125
  }
126
126
  get servicesLoader() {
127
127
  return {
128
- datasets: () => import("../mapbox-sdk/datasets.js").then((e) => e.datasets),
129
- directions: () => import("../mapbox-sdk/directions.js").then((e) => e.directions),
130
- geocoding: () => import("../mapbox-sdk/geocoding.js").then((e) => e.geocoding),
131
- geocodingV6: () => import("../mapbox-sdk/geocoding-v6.js").then((e) => e.geocodingV6),
132
- mapMatching: () => import("../mapbox-sdk/map-matching.js").then((e) => e.mapMatching),
133
- matrix: () => import("../mapbox-sdk/matrix.js").then((e) => e.matrix),
134
- optimization: () => import("../mapbox-sdk/optimization.js").then((e) => e.optimization),
135
- static: () => import("../mapbox-sdk/static.js").then((e) => e._static),
136
- styles: () => import("../mapbox-sdk/styles.js").then((e) => e.styles),
137
- tilequery: () => import("../mapbox-sdk/tilequery.js").then((e) => e.tilequery),
138
- tilesets: () => import("../mapbox-sdk/tilesets.js").then((e) => e.tilesets),
139
- tokens: () => import("../mapbox-sdk/tokens.js").then((e) => e.tokens),
140
- uploads: () => import("../mapbox-sdk/uploads.js").then((e) => e.uploads),
141
- isochrone: () => import("../mapbox-sdk/isochrone.js").then((e) => e.isochrone)
128
+ datasets: () => import("@mapbox/mapbox-sdk/services/datasets.js"),
129
+ directions: () => import("@mapbox/mapbox-sdk/services/directions.js"),
130
+ geocoding: () => import("@mapbox/mapbox-sdk/services/geocoding.js"),
131
+ geocodingV6: () => import("@mapbox/mapbox-sdk/services/geocoding-v6.js"),
132
+ mapMatching: () => import("@mapbox/mapbox-sdk/services/map-matching.js"),
133
+ matrix: () => import("@mapbox/mapbox-sdk/services/matrix.js"),
134
+ optimization: () => import("@mapbox/mapbox-sdk/services/optimization.js"),
135
+ static: () => import("@mapbox/mapbox-sdk/services/static.js"),
136
+ styles: () => import("@mapbox/mapbox-sdk/services/styles.js"),
137
+ tilequery: () => import("@mapbox/mapbox-sdk/services/tilequery.js"),
138
+ tilesets: () => import("@mapbox/mapbox-sdk/services/tilesets.js"),
139
+ tokens: () => import("@mapbox/mapbox-sdk/services/tokens.js"),
140
+ uploads: () => import("@mapbox/mapbox-sdk/services/uploads.js"),
141
+ isochrone: () => import("@mapbox/mapbox-sdk/services/isochrone.js")
142
142
  };
143
143
  }
144
144
  async loadMapboxSDK() {
145
- const s = (await import("../mapbox-sdk.js").then((o) => o.index)).default({ accessToken: this.apiKey }), a = await Promise.all(this.services.map((o) => this.servicesLoader[o]().then((r) => r.default(s))));
146
- for (const [o, r] of this.services.entries())
147
- this.sdk[r] = a[o];
145
+ const s = (await import("@mapbox/mapbox-sdk")).default({ accessToken: this.apiKey }), a = await Promise.all(this.services.map((r) => this.servicesLoader[r]().then((o) => o.default(s))));
146
+ for (const [r, o] of this.services.entries())
147
+ this.sdk[o] = a[r];
148
148
  }
149
149
  async getSDK() {
150
150
  return await (Object.keys(this.sdk).length ? Promise.resolve() : this.loadMapboxSDK()), this.sdk;
151
151
  }
152
- async createMap(e, s = {}) {
152
+ async createMap(t, s = {}) {
153
153
  const a = new k();
154
- return new Promise((o, r) => {
154
+ return new Promise((r, o) => {
155
155
  M(async () => {
156
156
  await (this.mapboxgl ? Promise.resolve() : this.loadMapbox());
157
157
  const i = () => {
158
- if (!e.value)
158
+ if (!t.value)
159
159
  throw new Error("Missing HTML element");
160
160
  a.map = new this.mapboxgl.Map({
161
- container: e.value,
161
+ container: t.value,
162
162
  accessToken: this.apiKey,
163
163
  ...s
164
164
  }), a.map.on("load", () => {
165
- o(a);
165
+ r(a);
166
166
  });
167
167
  };
168
168
  s.onMounted ? s.onMounted(i) : i();
@@ -1,17 +1,17 @@
1
- import { defineComponent as m, ref as f, toRefs as y, shallowRef as v, provide as b, h as g, inject as x, onMounted as M, onUnmounted as L, watch as d, nextTick as w } from "vue";
1
+ import { defineComponent as m, ref as f, toRefs as y, shallowRef as v, provide as b, h as x, inject as g, onMounted as M, onUnmounted as L, watch as h, nextTick as w } from "vue";
2
2
  class S {
3
3
  constructor() {
4
4
  this.overlay = null, this.watching = { layers: !1 };
5
5
  }
6
- watchLayers(e, s = {}) {
6
+ watchLayers(t, s = {}) {
7
7
  if (!this.overlay)
8
8
  throw new Error("overlay should be set");
9
9
  if (this.watching.layers) {
10
10
  console.warn("No need to call MapboxDeckGLOverlay.watchLayers(). layers are already being watched");
11
11
  return;
12
12
  }
13
- this.watching.layers = !0, d(e, () => {
14
- this.overlay.setProps({ layers: e.value });
13
+ this.watching.layers = !0, h(t, () => {
14
+ this.overlay.setProps({ layers: t.value });
15
15
  }, s);
16
16
  }
17
17
  }
@@ -19,62 +19,62 @@ class k {
19
19
  constructor() {
20
20
  this.map = null, this.watching = { sources: !1, layers: !1 };
21
21
  }
22
- watchSources(e, s = {}) {
22
+ watchSources(t, s = {}) {
23
23
  if (!this.map)
24
24
  throw new Error("map should be set");
25
25
  if (this.watching.sources) {
26
26
  console.warn("No need to call MapboxMap.watchSources(). sources are already being watched");
27
27
  return;
28
28
  }
29
- this.watching.sources = !0, d(e, (a, o) => {
30
- const r = [...o || []], i = [...a || []], n = i.map((t) => t.id), l = r.map((t) => t.id), c = i.filter((t) => !l.includes(t.id)), h = r.filter((t) => !n.includes(t.id));
31
- for (const t of h)
29
+ this.watching.sources = !0, h(t, (a, r) => {
30
+ const o = [...r || []], i = [...a || []], n = i.map((e) => e.id), l = o.map((e) => e.id), c = i.filter((e) => !l.includes(e.id)), d = o.filter((e) => !n.includes(e.id));
31
+ for (const e of d)
32
32
  w(() => {
33
- this.map.removeSource(t.id);
33
+ this.map.removeSource(e.id);
34
34
  });
35
- for (const t of c) {
36
- const u = { ...t };
37
- delete u.id, this.map.addSource(t.id, u);
35
+ for (const e of c) {
36
+ const u = { ...e };
37
+ delete u.id, this.map.addSource(e.id, u);
38
38
  }
39
39
  }, s);
40
40
  }
41
- watchLayers(e, s = {}) {
41
+ watchLayers(t, s = {}) {
42
42
  if (!this.map)
43
43
  throw new Error("map should be set");
44
44
  if (this.watching.layers) {
45
45
  console.warn("No need to call MapboxMap.watchLayers(). layers are already being watched");
46
46
  return;
47
47
  }
48
- this.watching.layers = !0, d(e, (a, o) => {
49
- const r = [...o || []], i = [...a || []], n = i.map((t) => t.id), l = r.map((t) => t.id), c = i.filter((t) => !l.includes(t.id)), h = r.filter((t) => !n.includes(t.id));
50
- for (const t of h)
51
- this.map.removeLayer(t.id);
52
- for (const t of c)
48
+ this.watching.layers = !0, h(t, (a, r) => {
49
+ const o = [...r || []], i = [...a || []], n = i.map((e) => e.id), l = o.map((e) => e.id), c = i.filter((e) => !l.includes(e.id)), d = o.filter((e) => !n.includes(e.id));
50
+ for (const e of d)
51
+ this.map.removeLayer(e.id);
52
+ for (const e of c)
53
53
  w(() => {
54
- this.map.addLayer(t);
54
+ this.map.addLayer(e);
55
55
  });
56
56
  }, s);
57
57
  }
58
- async setDeckGLOverlay(e = {}) {
58
+ async setDeckGLOverlay(t = {}) {
59
59
  if (!this.map)
60
60
  throw new Error("map should be set");
61
61
  const { MapboxOverlay: s } = await import("@deck.gl/mapbox"), a = new S();
62
- return a.overlay = new s(e), this.map.addControl(a.overlay), a;
62
+ return a.overlay = new s(t), this.map.addControl(a.overlay), a;
63
63
  }
64
64
  }
65
65
  class O {
66
- constructor(e) {
67
- if (this.apiKey = e.apiKey, !this.apiKey)
66
+ constructor(t) {
67
+ if (this.apiKey = t.apiKey, !this.apiKey)
68
68
  throw new Error("apiKey is required");
69
- this.services = e.services || [], this.sdk = {}, this.mapboxgl = null, this.services.length && this.loadMapboxSDK();
69
+ this.services = t.services || [], this.sdk = {}, this.mapboxgl = null, this.services.length && this.loadMapboxSDK();
70
70
  }
71
71
  get Map() {
72
72
  return m(
73
- (e, { emit: s, slots: a }) => {
74
- const o = f(null), { options: r, layers: i, sources: n } = y(e), l = v(null);
75
- return b("mapboxMap", l), this.createMap(o, r.value).then((c) => {
76
- l.value = c, c.watchSources(n, r.value.watchSourcesOptions || { immediate: !0 }), c.watchLayers(i, r.value.watchLayersOptions || { immediate: !0 }), s("loaded", c);
77
- }), () => g("div", { ref: o }, l.value ? a : []);
73
+ (t, { emit: s, slots: a }) => {
74
+ const r = f(null), { options: o, layers: i, sources: n } = y(t), l = v(null);
75
+ return b("mapboxMap", l), this.createMap(r, o.value).then((c) => {
76
+ l.value = c, c.watchSources(n, o.value.watchSourcesOptions || { immediate: !0 }), c.watchLayers(i, o.value.watchLayersOptions || { immediate: !0 }), s("loaded", c);
77
+ }), () => x("div", { ref: r }, l.value ? a : []);
78
78
  },
79
79
  {
80
80
  props: {
@@ -96,12 +96,12 @@ class O {
96
96
  }
97
97
  get DeckGLOverlay() {
98
98
  return m(
99
- (e, { emit: s, slots: a }) => {
100
- const { options: o, layers: r } = y(e), i = x("mapboxMap");
99
+ (t, { emit: s, slots: a }) => {
100
+ const { options: r, layers: o } = y(t), i = g("mapboxMap");
101
101
  if (!i || !i.value)
102
102
  throw new Error("map should exist");
103
- return i.value.setDeckGLOverlay(o.value).then((n) => {
104
- n.watchLayers(r, o.value.watchLayersOptions || { immediate: !0 }), s("loaded", n);
103
+ return i.value.setDeckGLOverlay(r.value).then((n) => {
104
+ n.watchLayers(o, r.value.watchLayersOptions || { immediate: !0 }), s("loaded", n);
105
105
  }), () => {
106
106
  };
107
107
  },
@@ -120,49 +120,49 @@ class O {
120
120
  );
121
121
  }
122
122
  async loadMapbox() {
123
- const e = await import("../mapbox-gl.js").then((s) => s.mapboxGl);
124
- this.mapboxgl = e;
123
+ const t = await import("../mapbox-gl.js").then((s) => s.mapboxGl);
124
+ this.mapboxgl = t;
125
125
  }
126
126
  get servicesLoader() {
127
127
  return {
128
- datasets: () => import("../mapbox-sdk/datasets.js").then((e) => e.datasets),
129
- directions: () => import("../mapbox-sdk/directions.js").then((e) => e.directions),
130
- geocoding: () => import("../mapbox-sdk/geocoding.js").then((e) => e.geocoding),
131
- geocodingV6: () => import("../mapbox-sdk/geocoding-v6.js").then((e) => e.geocodingV6),
132
- mapMatching: () => import("../mapbox-sdk/map-matching.js").then((e) => e.mapMatching),
133
- matrix: () => import("../mapbox-sdk/matrix.js").then((e) => e.matrix),
134
- optimization: () => import("../mapbox-sdk/optimization.js").then((e) => e.optimization),
135
- static: () => import("../mapbox-sdk/static.js").then((e) => e._static),
136
- styles: () => import("../mapbox-sdk/styles.js").then((e) => e.styles),
137
- tilequery: () => import("../mapbox-sdk/tilequery.js").then((e) => e.tilequery),
138
- tilesets: () => import("../mapbox-sdk/tilesets.js").then((e) => e.tilesets),
139
- tokens: () => import("../mapbox-sdk/tokens.js").then((e) => e.tokens),
140
- uploads: () => import("../mapbox-sdk/uploads.js").then((e) => e.uploads),
141
- isochrone: () => import("../mapbox-sdk/isochrone.js").then((e) => e.isochrone)
128
+ datasets: () => import("@mapbox/mapbox-sdk/services/datasets.js"),
129
+ directions: () => import("@mapbox/mapbox-sdk/services/directions.js"),
130
+ geocoding: () => import("@mapbox/mapbox-sdk/services/geocoding.js"),
131
+ geocodingV6: () => import("@mapbox/mapbox-sdk/services/geocoding-v6.js"),
132
+ mapMatching: () => import("@mapbox/mapbox-sdk/services/map-matching.js"),
133
+ matrix: () => import("@mapbox/mapbox-sdk/services/matrix.js"),
134
+ optimization: () => import("@mapbox/mapbox-sdk/services/optimization.js"),
135
+ static: () => import("@mapbox/mapbox-sdk/services/static.js"),
136
+ styles: () => import("@mapbox/mapbox-sdk/services/styles.js"),
137
+ tilequery: () => import("@mapbox/mapbox-sdk/services/tilequery.js"),
138
+ tilesets: () => import("@mapbox/mapbox-sdk/services/tilesets.js"),
139
+ tokens: () => import("@mapbox/mapbox-sdk/services/tokens.js"),
140
+ uploads: () => import("@mapbox/mapbox-sdk/services/uploads.js"),
141
+ isochrone: () => import("@mapbox/mapbox-sdk/services/isochrone.js")
142
142
  };
143
143
  }
144
144
  async loadMapboxSDK() {
145
- const s = (await import("../mapbox-sdk.js").then((o) => o.index)).default({ accessToken: this.apiKey }), a = await Promise.all(this.services.map((o) => this.servicesLoader[o]().then((r) => r.default(s))));
146
- for (const [o, r] of this.services.entries())
147
- this.sdk[r] = a[o];
145
+ const s = (await import("@mapbox/mapbox-sdk")).default({ accessToken: this.apiKey }), a = await Promise.all(this.services.map((r) => this.servicesLoader[r]().then((o) => o.default(s))));
146
+ for (const [r, o] of this.services.entries())
147
+ this.sdk[o] = a[r];
148
148
  }
149
149
  async getSDK() {
150
150
  return await (Object.keys(this.sdk).length ? Promise.resolve() : this.loadMapboxSDK()), this.sdk;
151
151
  }
152
- async createMap(e, s = {}) {
152
+ async createMap(t, s = {}) {
153
153
  const a = new k();
154
- return new Promise((o, r) => {
154
+ return new Promise((r, o) => {
155
155
  M(async () => {
156
156
  await (this.mapboxgl ? Promise.resolve() : this.loadMapbox());
157
157
  const i = () => {
158
- if (!e.value)
158
+ if (!t.value)
159
159
  throw new Error("Missing HTML element");
160
160
  a.map = new this.mapboxgl.Map({
161
- container: e.value,
161
+ container: t.value,
162
162
  accessToken: this.apiKey,
163
163
  ...s
164
164
  }), a.map.on("load", () => {
165
- o(a);
165
+ r(a);
166
166
  });
167
167
  };
168
168
  s.onMounted ? s.onMounted(i) : i();
@@ -174,8 +174,8 @@ class O {
174
174
  }
175
175
  class K extends O {
176
176
  async loadMapbox() {
177
- const e = await import("maplibre-gl");
178
- this.mapboxgl = e;
177
+ const t = await import("maplibre-gl");
178
+ this.mapboxgl = t;
179
179
  }
180
180
  }
181
181
  export {