@gui-chat-plugin/google-map 0.3.0
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.
- package/README.md +126 -0
- package/dist/core/definition.d.ts +66 -0
- package/dist/core/definition.d.ts.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/plugin.d.ts +9 -0
- package/dist/core/plugin.d.ts.map +1 -0
- package/dist/core/samples.d.ts +3 -0
- package/dist/core/samples.d.ts.map +1 -0
- package/dist/core/types.d.ts +75 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core.cjs +76 -0
- package/dist/core.js +458 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/style.css +1 -0
- package/dist/vue/Preview.vue.d.ts +9 -0
- package/dist/vue/Preview.vue.d.ts.map +1 -0
- package/dist/vue/View.vue.d.ts +11 -0
- package/dist/vue/View.vue.d.ts.map +1 -0
- package/dist/vue/index.d.ts +15 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue.cjs +1 -0
- package/dist/vue.js +516 -0
- package/package.json +57 -0
package/dist/vue.js
ADDED
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import { samples as se, pluginCore as re } from "./core.js";
|
|
2
|
+
import { TOOL_DEFINITION as je, TOOL_NAME as Be, executeMap as Qe } from "./core.js";
|
|
3
|
+
import { defineComponent as j, ref as g, computed as _, watch as ne, onMounted as ae, onUnmounted as le, createElementBlock as l, openBlock as i, createElementVNode as r, createCommentVNode as f, toDisplayString as d, Fragment as G, renderList as U, createTextVNode as T, normalizeClass as I } from "vue";
|
|
4
|
+
const ie = { class: "w-full h-full bg-white flex flex-col relative" }, ce = { class: "p-4 border-b border-gray-200" }, ue = { class: "text-xl font-bold text-gray-800" }, de = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "text-gray-600 text-sm"
|
|
7
|
+
}, ge = { class: "flex-1 min-h-0 flex" }, ve = { class: "flex-1 relative" }, me = {
|
|
8
|
+
key: 1,
|
|
9
|
+
class: "w-full h-full flex items-center justify-center bg-gray-100"
|
|
10
|
+
}, pe = { class: "text-center p-8" }, fe = ["href"], ye = {
|
|
11
|
+
key: 2,
|
|
12
|
+
class: "absolute inset-0 bg-white bg-opacity-75 flex items-center justify-center"
|
|
13
|
+
}, he = {
|
|
14
|
+
key: 3,
|
|
15
|
+
class: "absolute bottom-4 left-4 right-4 bg-red-100 border border-red-300 text-red-700 px-4 py-3 rounded"
|
|
16
|
+
}, we = {
|
|
17
|
+
key: 4,
|
|
18
|
+
class: "absolute top-4 right-4 flex flex-col gap-1"
|
|
19
|
+
}, be = {
|
|
20
|
+
key: 0,
|
|
21
|
+
class: "w-80 border-l border-gray-200 overflow-y-auto"
|
|
22
|
+
}, xe = {
|
|
23
|
+
key: 0,
|
|
24
|
+
class: "p-4"
|
|
25
|
+
}, _e = { class: "space-y-3" }, ke = ["onClick"], Me = { class: "font-medium text-gray-800" }, Ce = { class: "text-sm text-gray-600 mt-1" }, Le = {
|
|
26
|
+
key: 0,
|
|
27
|
+
class: "flex items-center mt-1"
|
|
28
|
+
}, De = { class: "text-sm text-gray-600" }, Pe = {
|
|
29
|
+
key: 0,
|
|
30
|
+
class: "text-gray-400"
|
|
31
|
+
}, Re = {
|
|
32
|
+
key: 1,
|
|
33
|
+
class: "p-4"
|
|
34
|
+
}, Ee = { class: "bg-blue-50 rounded-lg p-3 mb-4" }, Se = { class: "text-lg font-medium text-gray-800" }, Ze = { class: "text-gray-600" }, $e = { class: "text-sm text-gray-600 mb-3" }, Oe = { class: "space-y-2" }, Te = ["innerHTML"], Ie = { class: "text-gray-500 mt-1" }, ze = /* @__PURE__ */ j({
|
|
35
|
+
__name: "View",
|
|
36
|
+
props: {
|
|
37
|
+
selectedResult: {},
|
|
38
|
+
googleMapKey: {},
|
|
39
|
+
onUpdateResult: { type: Function }
|
|
40
|
+
},
|
|
41
|
+
setup(C) {
|
|
42
|
+
const u = C, k = g(null), n = g(null), b = g(/* @__PURE__ */ new Map()), L = g(null), D = g(null), s = g(null), h = g(null), P = g(!1), R = g(null), M = g([]), y = g(null), Z = g(null), E = g(15), B = _(() => {
|
|
43
|
+
const e = u.selectedResult?.data?.action;
|
|
44
|
+
return {
|
|
45
|
+
showLocation: "Map Location",
|
|
46
|
+
setCenter: "Map View",
|
|
47
|
+
setZoom: "Map View",
|
|
48
|
+
addMarker: "Map Marker",
|
|
49
|
+
clearMarkers: "Map",
|
|
50
|
+
findPlaces: "Place Search",
|
|
51
|
+
getDirections: "Directions"
|
|
52
|
+
}[e || "showLocation"] || "Map";
|
|
53
|
+
}), z = _(() => {
|
|
54
|
+
const e = u.selectedResult?.data;
|
|
55
|
+
if (!e) return "";
|
|
56
|
+
switch (e.action) {
|
|
57
|
+
case "showLocation":
|
|
58
|
+
case "setCenter":
|
|
59
|
+
case "addMarker":
|
|
60
|
+
return N(e.location);
|
|
61
|
+
case "setZoom":
|
|
62
|
+
return `Zoom level: ${e.zoom}`;
|
|
63
|
+
case "findPlaces":
|
|
64
|
+
return e.searchQuery || e.placeType || "";
|
|
65
|
+
case "getDirections":
|
|
66
|
+
return `${e.origin} → ${e.destination}`;
|
|
67
|
+
default:
|
|
68
|
+
return "";
|
|
69
|
+
}
|
|
70
|
+
}), Q = _(() => M.value.length > 0 || y.value !== null), A = _(() => {
|
|
71
|
+
const e = u.selectedResult?.data;
|
|
72
|
+
if (!e?.location) return "";
|
|
73
|
+
const t = N(e.location);
|
|
74
|
+
return `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(t)}`;
|
|
75
|
+
}), N = (e) => e ? typeof e == "string" ? e : `${e.lat}, ${e.lng}` : "", H = () => {
|
|
76
|
+
const e = [];
|
|
77
|
+
return b.value.forEach((t, o) => {
|
|
78
|
+
const a = t.getPosition();
|
|
79
|
+
a && e.push({
|
|
80
|
+
id: o,
|
|
81
|
+
position: { lat: a.lat(), lng: a.lng() },
|
|
82
|
+
title: t.getTitle() || void 0,
|
|
83
|
+
label: typeof t.getLabel() == "string" ? t.getLabel() : t.getLabel()?.text
|
|
84
|
+
});
|
|
85
|
+
}), e;
|
|
86
|
+
}, w = (e, t, o) => {
|
|
87
|
+
if (!u.onUpdateResult) return;
|
|
88
|
+
const v = {
|
|
89
|
+
action: u.selectedResult?.data?.action || "showLocation",
|
|
90
|
+
success: e,
|
|
91
|
+
center: Z.value || void 0,
|
|
92
|
+
zoom: E.value,
|
|
93
|
+
markers: H(),
|
|
94
|
+
...o
|
|
95
|
+
};
|
|
96
|
+
t && (v.error = t), u.onUpdateResult(v);
|
|
97
|
+
}, W = () => new Promise((e, t) => {
|
|
98
|
+
if (typeof google < "u" && google.maps) {
|
|
99
|
+
e();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const o = document.querySelector(
|
|
103
|
+
'script[src*="maps.googleapis.com"]'
|
|
104
|
+
);
|
|
105
|
+
if (o) {
|
|
106
|
+
o.addEventListener("load", () => e()), o.addEventListener(
|
|
107
|
+
"error",
|
|
108
|
+
() => t(new Error("Failed to load Google Maps"))
|
|
109
|
+
);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const a = document.createElement("script");
|
|
113
|
+
a.src = `https://maps.googleapis.com/maps/api/js?key=${u.googleMapKey}&libraries=places`, a.async = !0, a.defer = !0, a.onload = () => e(), a.onerror = () => t(new Error("Failed to load Google Maps")), document.head.appendChild(a);
|
|
114
|
+
}), J = async () => {
|
|
115
|
+
if (!(!k.value || !u.googleMapKey))
|
|
116
|
+
try {
|
|
117
|
+
await W();
|
|
118
|
+
const e = { lat: 35.6812, lng: 139.7671 };
|
|
119
|
+
n.value = new google.maps.Map(k.value, {
|
|
120
|
+
center: e,
|
|
121
|
+
zoom: E.value,
|
|
122
|
+
mapTypeControl: !0,
|
|
123
|
+
streetViewControl: !0,
|
|
124
|
+
fullscreenControl: !0
|
|
125
|
+
}), h.value = new google.maps.Geocoder(), L.value = new google.maps.places.PlacesService(n.value), D.value = new google.maps.DirectionsService(), s.value = new google.maps.DirectionsRenderer(), s.value.setMap(n.value), n.value.addListener("center_changed", () => {
|
|
126
|
+
const t = n.value?.getCenter();
|
|
127
|
+
t && (Z.value = { lat: t.lat(), lng: t.lng() });
|
|
128
|
+
}), n.value.addListener("zoom_changed", () => {
|
|
129
|
+
E.value = n.value?.getZoom() || 15;
|
|
130
|
+
}), u.selectedResult?.data && await V(u.selectedResult.data);
|
|
131
|
+
} catch (e) {
|
|
132
|
+
R.value = e instanceof Error ? e.message : "Failed to initialize map";
|
|
133
|
+
}
|
|
134
|
+
}, F = async (e) => typeof e != "string" ? e : h.value ? new Promise((t) => {
|
|
135
|
+
h.value.geocode(
|
|
136
|
+
{ address: e },
|
|
137
|
+
(o, a) => {
|
|
138
|
+
if (a === "OK" && o && o[0]) {
|
|
139
|
+
const v = o[0].geometry.location;
|
|
140
|
+
t({ lat: v.lat(), lng: v.lng() });
|
|
141
|
+
} else
|
|
142
|
+
t(null);
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
}) : null, $ = (e, t, o, a) => {
|
|
146
|
+
const v = new google.maps.Marker({
|
|
147
|
+
position: e,
|
|
148
|
+
map: n.value,
|
|
149
|
+
title: o,
|
|
150
|
+
label: a ? { text: a, color: "white" } : void 0,
|
|
151
|
+
animation: google.maps.Animation.DROP
|
|
152
|
+
});
|
|
153
|
+
return b.value.set(t, v), v;
|
|
154
|
+
}, K = () => {
|
|
155
|
+
b.value.forEach((e) => {
|
|
156
|
+
e.setMap(null);
|
|
157
|
+
}), b.value.clear();
|
|
158
|
+
}, V = async (e) => {
|
|
159
|
+
if (n.value) {
|
|
160
|
+
P.value = !0, R.value = null;
|
|
161
|
+
try {
|
|
162
|
+
switch (e.action) {
|
|
163
|
+
case "showLocation":
|
|
164
|
+
case "setCenter": {
|
|
165
|
+
if (!e.location)
|
|
166
|
+
throw new Error("Location is required");
|
|
167
|
+
const t = await F(e.location);
|
|
168
|
+
if (!t)
|
|
169
|
+
throw new Error("Could not find location");
|
|
170
|
+
if (n.value.setCenter(t), Z.value = t, e.action === "showLocation") {
|
|
171
|
+
const o = `location_${Date.now()}`;
|
|
172
|
+
$(
|
|
173
|
+
t,
|
|
174
|
+
o,
|
|
175
|
+
typeof e.location == "string" ? e.location : void 0
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
w(!0);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case "setZoom": {
|
|
182
|
+
const t = e.zoom || 15;
|
|
183
|
+
n.value.setZoom(t), E.value = t, w(!0);
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
case "addMarker": {
|
|
187
|
+
if (!e.location)
|
|
188
|
+
throw new Error("Location is required for marker");
|
|
189
|
+
const t = await F(e.location);
|
|
190
|
+
if (!t)
|
|
191
|
+
throw new Error("Could not find location for marker");
|
|
192
|
+
const o = e.marker?.id || `marker_${Date.now()}`;
|
|
193
|
+
$(t, o, e.marker?.title, e.marker?.label), w(!0);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
case "clearMarkers": {
|
|
197
|
+
K(), s.value?.setDirections({
|
|
198
|
+
routes: [],
|
|
199
|
+
request: {}
|
|
200
|
+
}), M.value = [], y.value = null, w(!0);
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
case "findPlaces": {
|
|
204
|
+
await X(e.searchQuery, e.placeType);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case "getDirections": {
|
|
208
|
+
if (!e.origin || !e.destination)
|
|
209
|
+
throw new Error("Origin and destination are required");
|
|
210
|
+
await Y(
|
|
211
|
+
e.origin,
|
|
212
|
+
e.destination,
|
|
213
|
+
e.travelMode || "DRIVING"
|
|
214
|
+
);
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
} catch (t) {
|
|
219
|
+
const o = t instanceof Error ? t.message : "An error occurred";
|
|
220
|
+
R.value = o, w(!1, o);
|
|
221
|
+
} finally {
|
|
222
|
+
P.value = !1;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}, X = async (e, t) => {
|
|
226
|
+
if (!L.value || !n.value) return;
|
|
227
|
+
const o = n.value.getCenter();
|
|
228
|
+
if (!o) return;
|
|
229
|
+
const a = {
|
|
230
|
+
location: o,
|
|
231
|
+
radius: 5e3,
|
|
232
|
+
query: e || t || ""
|
|
233
|
+
};
|
|
234
|
+
return t && !e && (a.type = t), new Promise((v) => {
|
|
235
|
+
L.value.textSearch(
|
|
236
|
+
a,
|
|
237
|
+
(x, O) => {
|
|
238
|
+
if (O === google.maps.places.PlacesServiceStatus.OK && x) {
|
|
239
|
+
b.value.forEach((c, p) => {
|
|
240
|
+
p.startsWith("place_") && (c.setMap(null), b.value.delete(p));
|
|
241
|
+
});
|
|
242
|
+
const m = x.slice(0, 10).map(
|
|
243
|
+
(c, p) => {
|
|
244
|
+
const S = c.geometry?.location, q = S ? { lat: S.lat(), lng: S.lng() } : { lat: 0, lng: 0 };
|
|
245
|
+
return S && $(
|
|
246
|
+
q,
|
|
247
|
+
`place_${c.place_id}`,
|
|
248
|
+
c.name,
|
|
249
|
+
String(p + 1)
|
|
250
|
+
), {
|
|
251
|
+
placeId: c.place_id || "",
|
|
252
|
+
name: c.name || "",
|
|
253
|
+
address: c.formatted_address || "",
|
|
254
|
+
location: q,
|
|
255
|
+
rating: c.rating,
|
|
256
|
+
userRatingsTotal: c.user_ratings_total,
|
|
257
|
+
types: c.types,
|
|
258
|
+
openNow: c.opening_hours?.isOpen?.()
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
if (M.value = m, y.value = null, m.length > 0) {
|
|
263
|
+
const c = new google.maps.LatLngBounds();
|
|
264
|
+
m.forEach((p) => {
|
|
265
|
+
c.extend(p.location);
|
|
266
|
+
}), n.value?.fitBounds(c);
|
|
267
|
+
}
|
|
268
|
+
w(!0, void 0, { places: m });
|
|
269
|
+
} else
|
|
270
|
+
w(!1, "No places found");
|
|
271
|
+
v();
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
});
|
|
275
|
+
}, Y = async (e, t, o) => {
|
|
276
|
+
if (!D.value || !s.value) return;
|
|
277
|
+
const a = {
|
|
278
|
+
origin: e,
|
|
279
|
+
destination: t,
|
|
280
|
+
travelMode: o
|
|
281
|
+
};
|
|
282
|
+
return new Promise((v) => {
|
|
283
|
+
D.value.route(
|
|
284
|
+
a,
|
|
285
|
+
(x, O) => {
|
|
286
|
+
if (O === google.maps.DirectionsStatus.OK && x) {
|
|
287
|
+
s.value.setDirections(x);
|
|
288
|
+
const m = x.routes[0]?.legs[0];
|
|
289
|
+
if (m) {
|
|
290
|
+
const c = {
|
|
291
|
+
summary: x.routes[0].summary || "",
|
|
292
|
+
distance: m.distance?.text || "",
|
|
293
|
+
duration: m.duration?.text || "",
|
|
294
|
+
startAddress: m.start_address || "",
|
|
295
|
+
endAddress: m.end_address || "",
|
|
296
|
+
steps: m.steps?.map((p) => ({
|
|
297
|
+
instruction: p.instructions || "",
|
|
298
|
+
distance: p.distance?.text || "",
|
|
299
|
+
duration: p.duration?.text || "",
|
|
300
|
+
travelMode: p.travel_mode || ""
|
|
301
|
+
})) || [],
|
|
302
|
+
polyline: x.routes[0].overview_polyline || ""
|
|
303
|
+
};
|
|
304
|
+
y.value = c, M.value = [], w(!0, void 0, { route: c });
|
|
305
|
+
}
|
|
306
|
+
} else
|
|
307
|
+
w(!1, "Could not find directions");
|
|
308
|
+
v();
|
|
309
|
+
}
|
|
310
|
+
);
|
|
311
|
+
});
|
|
312
|
+
}, ee = (e) => {
|
|
313
|
+
n.value && (n.value.setCenter(e.location), n.value.setZoom(17));
|
|
314
|
+
}, te = () => {
|
|
315
|
+
if (!n.value) return;
|
|
316
|
+
const e = n.value.getZoom() || 15;
|
|
317
|
+
e < 21 && n.value.setZoom(e + 1);
|
|
318
|
+
}, oe = () => {
|
|
319
|
+
if (!n.value) return;
|
|
320
|
+
const e = n.value.getZoom() || 15;
|
|
321
|
+
e > 1 && n.value.setZoom(e - 1);
|
|
322
|
+
};
|
|
323
|
+
return ne(
|
|
324
|
+
() => u.selectedResult?.data,
|
|
325
|
+
async (e) => {
|
|
326
|
+
e && n.value && await V(e);
|
|
327
|
+
}
|
|
328
|
+
), ae(() => {
|
|
329
|
+
u.googleMapKey && J();
|
|
330
|
+
}), le(() => {
|
|
331
|
+
K();
|
|
332
|
+
}), (e, t) => (i(), l("div", ie, [
|
|
333
|
+
r("div", ce, [
|
|
334
|
+
r("h2", ue, d(B.value), 1),
|
|
335
|
+
z.value ? (i(), l("p", de, d(z.value), 1)) : f("", !0)
|
|
336
|
+
]),
|
|
337
|
+
r("div", ge, [
|
|
338
|
+
r("div", ve, [
|
|
339
|
+
C.googleMapKey ? (i(), l("div", {
|
|
340
|
+
key: 0,
|
|
341
|
+
ref_key: "mapContainer",
|
|
342
|
+
ref: k,
|
|
343
|
+
class: "w-full h-full"
|
|
344
|
+
}, null, 512)) : (i(), l("div", me, [
|
|
345
|
+
r("div", pe, [
|
|
346
|
+
t[0] || (t[0] = r("div", { class: "text-gray-500 mb-4" }, "Google Maps API key not configured", -1)),
|
|
347
|
+
A.value ? (i(), l("a", {
|
|
348
|
+
key: 0,
|
|
349
|
+
href: A.value,
|
|
350
|
+
target: "_blank",
|
|
351
|
+
class: "inline-block px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors"
|
|
352
|
+
}, " Open in Google Maps ", 8, fe)) : f("", !0)
|
|
353
|
+
])
|
|
354
|
+
])),
|
|
355
|
+
P.value ? (i(), l("div", ye, [...t[1] || (t[1] = [
|
|
356
|
+
r("div", { class: "text-gray-600" }, "Loading...", -1)
|
|
357
|
+
])])) : f("", !0),
|
|
358
|
+
R.value ? (i(), l("div", he, d(R.value), 1)) : f("", !0),
|
|
359
|
+
C.googleMapKey && n.value ? (i(), l("div", we, [
|
|
360
|
+
r("button", {
|
|
361
|
+
onClick: te,
|
|
362
|
+
class: "w-8 h-8 bg-white border border-gray-300 rounded shadow text-lg font-bold text-gray-700 hover:bg-gray-100 flex items-center justify-center",
|
|
363
|
+
title: "Zoom in"
|
|
364
|
+
}, " + "),
|
|
365
|
+
r("button", {
|
|
366
|
+
onClick: oe,
|
|
367
|
+
class: "w-8 h-8 bg-white border border-gray-300 rounded shadow text-lg font-bold text-gray-700 hover:bg-gray-100 flex items-center justify-center",
|
|
368
|
+
title: "Zoom out"
|
|
369
|
+
}, " − ")
|
|
370
|
+
])) : f("", !0)
|
|
371
|
+
]),
|
|
372
|
+
Q.value ? (i(), l("div", be, [
|
|
373
|
+
M.value.length > 0 ? (i(), l("div", xe, [
|
|
374
|
+
t[3] || (t[3] = r("h3", { class: "font-semibold text-gray-800 mb-3" }, "Search Results", -1)),
|
|
375
|
+
r("div", _e, [
|
|
376
|
+
(i(!0), l(G, null, U(M.value, (o) => (i(), l("div", {
|
|
377
|
+
key: o.placeId,
|
|
378
|
+
class: "p-3 bg-gray-50 rounded-lg cursor-pointer hover:bg-gray-100 transition-colors",
|
|
379
|
+
onClick: (a) => ee(o)
|
|
380
|
+
}, [
|
|
381
|
+
r("div", Me, d(o.name), 1),
|
|
382
|
+
r("div", Ce, d(o.address), 1),
|
|
383
|
+
o.rating ? (i(), l("div", Le, [
|
|
384
|
+
t[2] || (t[2] = r("span", { class: "text-yellow-500 mr-1" }, "★", -1)),
|
|
385
|
+
r("span", De, [
|
|
386
|
+
T(d(o.rating.toFixed(1)) + " ", 1),
|
|
387
|
+
o.userRatingsTotal ? (i(), l("span", Pe, " (" + d(o.userRatingsTotal) + ") ", 1)) : f("", !0)
|
|
388
|
+
])
|
|
389
|
+
])) : f("", !0),
|
|
390
|
+
o.openNow !== void 0 ? (i(), l("div", {
|
|
391
|
+
key: 1,
|
|
392
|
+
class: I([o.openNow ? "text-green-600" : "text-red-600", "text-sm mt-1"])
|
|
393
|
+
}, d(o.openNow ? "Open now" : "Closed"), 3)) : f("", !0)
|
|
394
|
+
], 8, ke))), 128))
|
|
395
|
+
])
|
|
396
|
+
])) : f("", !0),
|
|
397
|
+
y.value ? (i(), l("div", Re, [
|
|
398
|
+
t[6] || (t[6] = r("h3", { class: "font-semibold text-gray-800 mb-3" }, "Directions", -1)),
|
|
399
|
+
r("div", Ee, [
|
|
400
|
+
r("div", Se, d(y.value.distance), 1),
|
|
401
|
+
r("div", Ze, d(y.value.duration), 1)
|
|
402
|
+
]),
|
|
403
|
+
r("div", $e, [
|
|
404
|
+
r("div", null, [
|
|
405
|
+
t[4] || (t[4] = r("strong", null, "From:", -1)),
|
|
406
|
+
T(" " + d(y.value.startAddress), 1)
|
|
407
|
+
]),
|
|
408
|
+
r("div", null, [
|
|
409
|
+
t[5] || (t[5] = r("strong", null, "To:", -1)),
|
|
410
|
+
T(" " + d(y.value.endAddress), 1)
|
|
411
|
+
])
|
|
412
|
+
]),
|
|
413
|
+
r("div", Oe, [
|
|
414
|
+
(i(!0), l(G, null, U(y.value.steps, (o, a) => (i(), l("div", {
|
|
415
|
+
key: a,
|
|
416
|
+
class: "p-2 bg-gray-50 rounded text-sm"
|
|
417
|
+
}, [
|
|
418
|
+
r("div", {
|
|
419
|
+
innerHTML: o.instruction,
|
|
420
|
+
class: "text-gray-800"
|
|
421
|
+
}, null, 8, Te),
|
|
422
|
+
r("div", Ie, d(o.distance) + " · " + d(o.duration), 1)
|
|
423
|
+
]))), 128))
|
|
424
|
+
])
|
|
425
|
+
])) : f("", !0)
|
|
426
|
+
])) : f("", !0)
|
|
427
|
+
])
|
|
428
|
+
]));
|
|
429
|
+
}
|
|
430
|
+
}), Ae = { class: "text-xs text-gray-600 mt-1 truncate" }, Ne = /* @__PURE__ */ j({
|
|
431
|
+
__name: "Preview",
|
|
432
|
+
props: {
|
|
433
|
+
result: {}
|
|
434
|
+
},
|
|
435
|
+
setup(C) {
|
|
436
|
+
const u = C, k = (s) => s ? typeof s == "string" ? s : `${s.lat.toFixed(4)}, ${s.lng.toFixed(4)}` : "", n = _(() => {
|
|
437
|
+
const s = u.result.data?.action;
|
|
438
|
+
return {
|
|
439
|
+
showLocation: "Map Location",
|
|
440
|
+
setCenter: "Center Map",
|
|
441
|
+
setZoom: "Zoom",
|
|
442
|
+
addMarker: "Add Marker",
|
|
443
|
+
clearMarkers: "Clear Markers",
|
|
444
|
+
findPlaces: "Place Search",
|
|
445
|
+
getDirections: "Directions"
|
|
446
|
+
}[s || "showLocation"] || "Map";
|
|
447
|
+
}), b = _(() => {
|
|
448
|
+
const s = u.result.data;
|
|
449
|
+
if (!s) return "";
|
|
450
|
+
switch (s.action) {
|
|
451
|
+
case "showLocation":
|
|
452
|
+
case "setCenter":
|
|
453
|
+
case "addMarker":
|
|
454
|
+
return k(s.location);
|
|
455
|
+
case "setZoom":
|
|
456
|
+
return `Level ${s.zoom}`;
|
|
457
|
+
case "clearMarkers":
|
|
458
|
+
return "All markers cleared";
|
|
459
|
+
case "findPlaces":
|
|
460
|
+
return s.searchQuery || s.placeType || "Search";
|
|
461
|
+
case "getDirections": {
|
|
462
|
+
const h = typeof s.origin == "string" ? s.origin : "Start", P = typeof s.destination == "string" ? s.destination : "End";
|
|
463
|
+
return `${h} → ${P}`;
|
|
464
|
+
}
|
|
465
|
+
default:
|
|
466
|
+
return k(s.location);
|
|
467
|
+
}
|
|
468
|
+
}), L = _(() => {
|
|
469
|
+
const s = u.result.data?.action;
|
|
470
|
+
return {
|
|
471
|
+
showLocation: "bg-blue-50",
|
|
472
|
+
setCenter: "bg-blue-50",
|
|
473
|
+
setZoom: "bg-purple-50",
|
|
474
|
+
addMarker: "bg-green-50",
|
|
475
|
+
clearMarkers: "bg-gray-50",
|
|
476
|
+
findPlaces: "bg-yellow-50",
|
|
477
|
+
getDirections: "bg-orange-50"
|
|
478
|
+
}[s || "showLocation"] || "bg-blue-50";
|
|
479
|
+
}), D = _(() => {
|
|
480
|
+
const s = u.result.data?.action;
|
|
481
|
+
return {
|
|
482
|
+
showLocation: "text-blue-600",
|
|
483
|
+
setCenter: "text-blue-600",
|
|
484
|
+
setZoom: "text-purple-600",
|
|
485
|
+
addMarker: "text-green-600",
|
|
486
|
+
clearMarkers: "text-gray-600",
|
|
487
|
+
findPlaces: "text-yellow-700",
|
|
488
|
+
getDirections: "text-orange-600"
|
|
489
|
+
}[s || "showLocation"] || "text-blue-600";
|
|
490
|
+
});
|
|
491
|
+
return (s, h) => (i(), l("div", {
|
|
492
|
+
class: I(["text-center p-4 rounded", L.value])
|
|
493
|
+
}, [
|
|
494
|
+
r("div", {
|
|
495
|
+
class: I(["font-medium", D.value])
|
|
496
|
+
}, d(n.value), 3),
|
|
497
|
+
r("div", Ae, d(b.value), 1)
|
|
498
|
+
], 2));
|
|
499
|
+
}
|
|
500
|
+
}), Fe = {
|
|
501
|
+
...re,
|
|
502
|
+
viewComponent: ze,
|
|
503
|
+
previewComponent: Ne,
|
|
504
|
+
samples: se
|
|
505
|
+
}, qe = { plugin: Fe };
|
|
506
|
+
export {
|
|
507
|
+
Ne as Preview,
|
|
508
|
+
je as TOOL_DEFINITION,
|
|
509
|
+
Be as TOOL_NAME,
|
|
510
|
+
ze as View,
|
|
511
|
+
qe as default,
|
|
512
|
+
Qe as executeMap,
|
|
513
|
+
Fe as plugin,
|
|
514
|
+
re as pluginCore,
|
|
515
|
+
se as samples
|
|
516
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gui-chat-plugin/google-map",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Google Map location plugin for GUI Chat applications",
|
|
6
|
+
"author": "receptron",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
},
|
|
17
|
+
"./vue": {
|
|
18
|
+
"types": "./dist/vue/index.d.ts",
|
|
19
|
+
"import": "./dist/vue.js",
|
|
20
|
+
"require": "./dist/vue.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./style.css": "./dist/style.css"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"dev": "vite",
|
|
29
|
+
"build": "vite build && vue-tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
30
|
+
"typecheck": "vue-tsc --noEmit",
|
|
31
|
+
"lint": "eslint src"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"gui-chat-protocol": "^0.0.3"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@eslint/js": "^9.0.0",
|
|
38
|
+
"@tailwindcss/vite": "^4.1.0",
|
|
39
|
+
"@types/google.maps": "^3.58.1",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^8.53.1",
|
|
41
|
+
"@typescript-eslint/parser": "^8.53.1",
|
|
42
|
+
"@vitejs/plugin-vue": "^6.0.0",
|
|
43
|
+
"eslint": "^9.0.0",
|
|
44
|
+
"eslint-plugin-vue": "^10.0.0",
|
|
45
|
+
"globals": "^17.1.0",
|
|
46
|
+
"openai": "^6.16.0",
|
|
47
|
+
"tailwindcss": "^4.1.0",
|
|
48
|
+
"typescript": "^5.8.0",
|
|
49
|
+
"vite": "^7.0.0",
|
|
50
|
+
"vue": "^3.5.0",
|
|
51
|
+
"vue-eslint-parser": "^10.0.0",
|
|
52
|
+
"vue-tsc": "^3.2.3"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"vue": "^3.5.0"
|
|
56
|
+
}
|
|
57
|
+
}
|