@appsoftwareltd/etherpk-mcp 0.9.4 → 0.9.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.
- package/dist/main.js +47 -4
- package/dist/main.js.map +1 -1
- package/dist/map-picture-page.js +100 -65
- package/package.json +5 -5
package/dist/map-picture-page.js
CHANGED
|
@@ -83,7 +83,20 @@ function u(e) {
|
|
|
83
83
|
}
|
|
84
84
|
//#endregion
|
|
85
85
|
//#region ../../extensions/maps/src/map-drawing.ts
|
|
86
|
-
|
|
86
|
+
var d = {
|
|
87
|
+
center: [0, 20],
|
|
88
|
+
zoom: .8
|
|
89
|
+
}, f = "…";
|
|
90
|
+
function p(e, t, n) {
|
|
91
|
+
if (n(e) <= t) return e;
|
|
92
|
+
let r = Array.from(e);
|
|
93
|
+
for (let e = r.length - 1; e >= 0; e--) {
|
|
94
|
+
let i = `${r.slice(0, e).join("").trimEnd()}${f}`;
|
|
95
|
+
if (n(i) <= t) return i;
|
|
96
|
+
}
|
|
97
|
+
return "";
|
|
98
|
+
}
|
|
99
|
+
function m(e, t) {
|
|
87
100
|
let n = t ? "#0b0d10" : "#ffffff", r = t ? "#7cc4ff" : "#1d5fd1", i = t ? "#ffd166" : "#c2410c", a = {
|
|
88
101
|
"line-cap": "round",
|
|
89
102
|
"line-join": "round"
|
|
@@ -118,7 +131,7 @@ function d(e, t) {
|
|
|
118
131
|
}
|
|
119
132
|
}];
|
|
120
133
|
}
|
|
121
|
-
function
|
|
134
|
+
function h(e) {
|
|
122
135
|
return {
|
|
123
136
|
version: 8,
|
|
124
137
|
sources: {},
|
|
@@ -131,12 +144,12 @@ function f(e) {
|
|
|
131
144
|
}
|
|
132
145
|
//#endregion
|
|
133
146
|
//#region ../../extensions/maps/src/map-geometry.ts
|
|
134
|
-
function
|
|
147
|
+
function g(e) {
|
|
135
148
|
return e.kind === "place" ? [e.point] : e.points;
|
|
136
149
|
}
|
|
137
|
-
function
|
|
150
|
+
function _(e) {
|
|
138
151
|
let t = Infinity, n = -Infinity, r = Infinity, i = -Infinity, a = Infinity, o = -Infinity;
|
|
139
|
-
for (let s of e) for (let { lat: e, lon: c } of
|
|
152
|
+
for (let s of e) for (let { lat: e, lon: c } of g(s)) {
|
|
140
153
|
e < t && (t = e), e > n && (n = e), c < r && (r = c), c > i && (i = c);
|
|
141
154
|
let s = c < 0 ? c + 360 : c;
|
|
142
155
|
s < a && (a = s), s > o && (o = s);
|
|
@@ -153,13 +166,34 @@ function m(e) {
|
|
|
153
166
|
north: n
|
|
154
167
|
};
|
|
155
168
|
}
|
|
156
|
-
|
|
169
|
+
function v(e, t, n) {
|
|
170
|
+
let r = Math.min(1, e * .5 / (n.left + n.right)), i = Math.min(1, t * .5 / (n.top + n.bottom));
|
|
171
|
+
return {
|
|
172
|
+
top: n.top * i,
|
|
173
|
+
bottom: n.bottom * i,
|
|
174
|
+
left: n.left * r,
|
|
175
|
+
right: n.right * r
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
var y = 2, b = 2e4, x = {
|
|
157
179
|
top: 48,
|
|
158
180
|
bottom: 40,
|
|
159
181
|
left: 40,
|
|
160
182
|
right: 40
|
|
161
|
-
},
|
|
162
|
-
|
|
183
|
+
}, S = .4, C = 4, w = "etherpk-picture-routes", T = "M12 31c-1-3-10-12-10-19a10 10 0 0 1 20 0c0 7-9 16-10 19z", E = "system-ui, -apple-system, \"Segoe UI\", sans-serif", D = {
|
|
184
|
+
pin: "#1d5fd1",
|
|
185
|
+
pinEdge: "#ffffff",
|
|
186
|
+
plate: "rgba(255, 255, 255, 0.92)",
|
|
187
|
+
name: "#111827",
|
|
188
|
+
credit: "#374151"
|
|
189
|
+
}, O = {
|
|
190
|
+
pin: "#7cc4ff",
|
|
191
|
+
pinEdge: "#0b0d10",
|
|
192
|
+
plate: "rgba(17, 20, 24, 0.92)",
|
|
193
|
+
name: "#f3f4f6",
|
|
194
|
+
credit: "#d1d5db"
|
|
195
|
+
};
|
|
196
|
+
function k(e) {
|
|
163
197
|
let t = /* @__PURE__ */ new Set();
|
|
164
198
|
for (let n of Object.keys(e.getStyle()?.sources ?? {})) {
|
|
165
199
|
let r = e.getSource(n)?.attribution;
|
|
@@ -169,24 +203,26 @@ function C(e) {
|
|
|
169
203
|
}
|
|
170
204
|
return [...t].join(" ");
|
|
171
205
|
}
|
|
172
|
-
function
|
|
206
|
+
function A(e, t, n, r) {
|
|
173
207
|
e.save(), e.translate(t - 12, n - 31), e.shadowColor = "rgba(0, 0, 0, 0.35)", e.shadowBlur = 2, e.shadowOffsetY = 1;
|
|
174
|
-
let
|
|
175
|
-
e.fillStyle =
|
|
208
|
+
let i = new Path2D(T);
|
|
209
|
+
e.fillStyle = r.pin, e.fill(i), e.shadowColor = "transparent", e.lineWidth = 1.5, e.strokeStyle = r.pinEdge, e.stroke(i), e.beginPath(), e.arc(12, 12, 4, 0, Math.PI * 2), e.fillStyle = r.pinEdge, e.fill(), e.restore();
|
|
176
210
|
}
|
|
177
|
-
var
|
|
178
|
-
function
|
|
179
|
-
e.font =
|
|
180
|
-
let
|
|
181
|
-
|
|
211
|
+
var j = `600 14px ${E}`, M = (e) => 14 + e + 12;
|
|
212
|
+
function N(e, t, n, r, i, a) {
|
|
213
|
+
e.font = j;
|
|
214
|
+
let o = p(r, i - C - M(0) - t, (t) => e.measureText(t).width);
|
|
215
|
+
if (o === "") return;
|
|
216
|
+
let s = e.measureText(o).width, c = t + 14, l = n - 29;
|
|
217
|
+
e.fillStyle = a.plate, e.beginPath(), e.roundRect(c, l, s + 12, 20, 4), e.fill(), e.fillStyle = a.name, e.textBaseline = "middle", e.fillText(o, c + 6, l + 10);
|
|
182
218
|
}
|
|
183
|
-
function
|
|
219
|
+
function P(e, t, n, r, i) {
|
|
184
220
|
if (t === "") return;
|
|
185
|
-
e.font = `14px ${
|
|
186
|
-
let
|
|
187
|
-
e.fillStyle =
|
|
221
|
+
e.font = `14px ${E}`;
|
|
222
|
+
let a = Math.min(e.measureText(t).width, n - 16);
|
|
223
|
+
e.fillStyle = i.plate, e.fillRect(n - a - 12, r - 24, a + 12, 24), e.fillStyle = i.credit, e.textBaseline = "middle", e.fillText(t, n - a - 6, r - 12, a);
|
|
188
224
|
}
|
|
189
|
-
async function
|
|
225
|
+
async function F(e) {
|
|
190
226
|
for (let t of ["image/webp", "image/png"]) {
|
|
191
227
|
let n = await new Promise((n) => e.toBlob(n, t, .9));
|
|
192
228
|
if (n && n.type === t) return {
|
|
@@ -196,9 +232,9 @@ async function k(e) {
|
|
|
196
232
|
}
|
|
197
233
|
throw Error("this browser couldn't save the picture");
|
|
198
234
|
}
|
|
199
|
-
function
|
|
235
|
+
function I(e) {
|
|
200
236
|
return new Promise((t, n) => {
|
|
201
|
-
let r = 0, i = setTimeout(() => n(/* @__PURE__ */ Error("the map took too long to draw. Keep EtherPK's tab in front while it publishes, then try again")),
|
|
237
|
+
let r = 0, i = setTimeout(() => n(/* @__PURE__ */ Error("the map took too long to draw. Keep EtherPK's tab in front while it publishes, then try again")), b);
|
|
202
238
|
e.on("error", (e) => {
|
|
203
239
|
let t = e;
|
|
204
240
|
if (t.tile !== void 0 || t.sourceId !== void 0) {
|
|
@@ -211,58 +247,57 @@ function A(e) {
|
|
|
211
247
|
});
|
|
212
248
|
});
|
|
213
249
|
}
|
|
214
|
-
async function
|
|
215
|
-
let { items:
|
|
250
|
+
async function L(t, n) {
|
|
251
|
+
let r = n.width ?? 800, i = n.height ?? 450, a = n.dark ?? !1, o = a ? O : D, { items: c } = s(t.split("\n"));
|
|
216
252
|
if (n.style !== null && typeof navigator < "u" && navigator.onLine === !1) throw Error("you're offline, and the map's tiles can't be fetched");
|
|
217
|
-
let
|
|
218
|
-
|
|
253
|
+
let l = document.createElement("div");
|
|
254
|
+
l.setAttribute("aria-hidden", "true"), Object.assign(l.style, {
|
|
219
255
|
position: "fixed",
|
|
220
256
|
left: "-10000px",
|
|
221
257
|
top: "0",
|
|
222
|
-
width:
|
|
223
|
-
height:
|
|
258
|
+
width: `${r}px`,
|
|
259
|
+
height: `${i}px`,
|
|
224
260
|
pointerEvents: "none"
|
|
225
|
-
}), document.body.appendChild(
|
|
226
|
-
let
|
|
261
|
+
}), document.body.appendChild(l);
|
|
262
|
+
let u = null;
|
|
227
263
|
try {
|
|
228
264
|
try {
|
|
229
|
-
|
|
230
|
-
container:
|
|
231
|
-
style: n.style ??
|
|
265
|
+
u = new e({
|
|
266
|
+
container: l,
|
|
267
|
+
style: n.style ?? h(a),
|
|
232
268
|
interactive: !1,
|
|
233
269
|
attributionControl: !1,
|
|
234
270
|
fadeDuration: 0,
|
|
235
|
-
pixelRatio:
|
|
271
|
+
pixelRatio: y,
|
|
236
272
|
canvasContextAttributes: { preserveDrawingBuffer: !0 },
|
|
237
|
-
|
|
238
|
-
zoom: .8
|
|
273
|
+
...d
|
|
239
274
|
});
|
|
240
275
|
} catch {
|
|
241
276
|
throw Error("this browser can't draw maps");
|
|
242
277
|
}
|
|
243
|
-
let t =
|
|
244
|
-
|
|
245
|
-
let
|
|
246
|
-
if (!
|
|
247
|
-
let
|
|
248
|
-
|
|
249
|
-
let
|
|
250
|
-
if (
|
|
251
|
-
let
|
|
252
|
-
|
|
253
|
-
padding: {
|
|
254
|
-
...
|
|
255
|
-
right:
|
|
256
|
-
},
|
|
278
|
+
let t = u, s = document.createElement("canvas");
|
|
279
|
+
s.width = r * y, s.height = i * y;
|
|
280
|
+
let f = s.getContext("2d");
|
|
281
|
+
if (!f) throw Error("this browser can't draw the picture");
|
|
282
|
+
let p = c.filter((e) => e.kind === "place"), g = p.length <= 30;
|
|
283
|
+
f.font = j;
|
|
284
|
+
let b = 0;
|
|
285
|
+
if (g) for (let e of p) e.name !== "" && (b = Math.max(b, M(f.measureText(e.name).width)));
|
|
286
|
+
let C = _(c);
|
|
287
|
+
C && t.fitBounds([[C.west, C.south], [C.east, C.north]], {
|
|
288
|
+
padding: v(r, i, {
|
|
289
|
+
...x,
|
|
290
|
+
right: x.right + Math.min(b, r * S)
|
|
291
|
+
}),
|
|
257
292
|
maxZoom: 14,
|
|
258
293
|
animate: !1
|
|
259
294
|
});
|
|
260
|
-
let
|
|
261
|
-
t.addSource(
|
|
295
|
+
let T = I(t), E = () => {
|
|
296
|
+
t.addSource(w, {
|
|
262
297
|
type: "geojson",
|
|
263
298
|
data: {
|
|
264
299
|
type: "FeatureCollection",
|
|
265
|
-
features:
|
|
300
|
+
features: c.flatMap((e) => e.kind === "route" ? [{
|
|
266
301
|
type: "Feature",
|
|
267
302
|
properties: { selected: !1 },
|
|
268
303
|
geometry: {
|
|
@@ -272,21 +307,21 @@ async function j(t, n) {
|
|
|
272
307
|
}] : [])
|
|
273
308
|
}
|
|
274
309
|
});
|
|
275
|
-
for (let e of
|
|
310
|
+
for (let e of m(w, a)) t.addLayer(e);
|
|
276
311
|
};
|
|
277
|
-
t.isStyleLoaded() ?
|
|
278
|
-
for (let e of
|
|
279
|
-
let { x: n, y:
|
|
280
|
-
|
|
312
|
+
t.isStyleLoaded() ? E() : t.once("style.load", E), await T, f.drawImage(t.getCanvas(), 0, 0, s.width, s.height), f.scale(y, y);
|
|
313
|
+
for (let e of p) {
|
|
314
|
+
let { x: n, y: i } = t.project([e.point.lon, e.point.lat]);
|
|
315
|
+
A(f, n, i, o), g && e.name !== "" && N(f, n, i, e.name, r, o);
|
|
281
316
|
}
|
|
282
|
-
return
|
|
283
|
-
...await
|
|
284
|
-
width:
|
|
285
|
-
height:
|
|
317
|
+
return P(f, k(t), r, i, o), {
|
|
318
|
+
...await F(s),
|
|
319
|
+
width: r,
|
|
320
|
+
height: i
|
|
286
321
|
};
|
|
287
322
|
} finally {
|
|
288
|
-
|
|
323
|
+
u?.remove(), l.remove();
|
|
289
324
|
}
|
|
290
325
|
}
|
|
291
|
-
t(new URL("/maplibre-gl-worker.mjs", location.href).toString()), window.etherpkDrawMapPicture =
|
|
326
|
+
t(new URL("/maplibre-gl-worker.mjs", location.href).toString()), window.etherpkDrawMapPicture = L;
|
|
292
327
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsoftwareltd/etherpk-mcp",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"license": "Elastic-2.0",
|
|
5
5
|
"description": "EtherPK Headless Client: an MCP server over a synced knowledge graph, run beside the agent on the user's own machine.",
|
|
6
6
|
"type": "module",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"typescript": "^6.0.2",
|
|
45
45
|
"vite": "^8.0.16",
|
|
46
46
|
"vitest": "^4.1.11",
|
|
47
|
-
"@appsoftwareltd/etherpk-extension-graph-view": "0.9.
|
|
48
|
-
"@appsoftwareltd/etherpk-extension-maps": "0.9.
|
|
49
|
-
"@appsoftwareltd/etherpk-
|
|
50
|
-
"@appsoftwareltd/etherpk-
|
|
47
|
+
"@appsoftwareltd/etherpk-extension-graph-view": "0.9.6",
|
|
48
|
+
"@appsoftwareltd/etherpk-extension-maps": "0.9.6",
|
|
49
|
+
"@appsoftwareltd/etherpk-themes": "0.9.6",
|
|
50
|
+
"@appsoftwareltd/etherpk-shared": "0.9.6"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|