@appsoftwareltd/etherpk-mcp 0.9.6 → 0.10.1
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 +22 -5
- package/dist/main.js +361 -81
- package/dist/main.js.map +1 -1
- package/dist/map-picture-page.js +73 -72
- package/package.json +5 -5
package/dist/map-picture-page.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Map as e, setWorkerUrl as t } from "maplibre-gl";
|
|
2
2
|
//#region ../client/src/lib/document/map-text.ts
|
|
3
|
-
var n = String.raw`[+-]?(?:\d+(?:\.\d*)?|\.\d+)`, r = new RegExp(String.raw`^\s*(${n})\s*,\s*(${n})\s*$`);
|
|
4
|
-
function
|
|
3
|
+
var n = String.raw`[+-]?(?:\d+(?:\.\d*)?|\.\d+)`, r = new RegExp(String.raw`^\s*(${n})\s*,\s*(${n})\s*$`), i = 16;
|
|
4
|
+
function a(e) {
|
|
5
5
|
let t = r.exec(e);
|
|
6
6
|
if (!t) return null;
|
|
7
7
|
let n = Number(t[1]), i = Number(t[2]);
|
|
@@ -10,15 +10,15 @@ function i(e) {
|
|
|
10
10
|
lon: i
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
let n = e.trim(), r = null,
|
|
15
|
-
if (
|
|
16
|
-
if (!n.endsWith(")") || (r = n.slice(
|
|
17
|
-
n = n.slice(0,
|
|
13
|
+
function o(e, t) {
|
|
14
|
+
let n = e.trim(), r = null, i = n.indexOf("(");
|
|
15
|
+
if (i >= 0) {
|
|
16
|
+
if (!n.endsWith(")") || (r = n.slice(i + 1, -1).trim(), r === "")) return null;
|
|
17
|
+
n = n.slice(0, i);
|
|
18
18
|
}
|
|
19
19
|
let o = [];
|
|
20
20
|
for (let e of n.split(">")) {
|
|
21
|
-
let t =
|
|
21
|
+
let t = a(e);
|
|
22
22
|
if (!t) return null;
|
|
23
23
|
o.push(t);
|
|
24
24
|
}
|
|
@@ -33,23 +33,24 @@ function a(e, t) {
|
|
|
33
33
|
track: r
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function s(e) {
|
|
37
37
|
let t = e.trim();
|
|
38
38
|
if (t === "") return null;
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
let n = 0;
|
|
40
|
+
for (let e = t.lastIndexOf("@"); e >= 0 && n < i; e = e === 0 ? -1 : t.lastIndexOf("@", e - 1), n++) {
|
|
41
|
+
let n = o(t.slice(e + 1), t.slice(0, e).trim());
|
|
41
42
|
if (n) return n;
|
|
42
43
|
}
|
|
43
|
-
return
|
|
44
|
+
return o(t, "");
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function c(e) {
|
|
46
47
|
let t = {
|
|
47
48
|
items: [],
|
|
48
49
|
unread: []
|
|
49
50
|
};
|
|
50
51
|
return e.forEach((e, n) => {
|
|
51
52
|
if (e.trim() === "") return;
|
|
52
|
-
let r =
|
|
53
|
+
let r = s(e);
|
|
53
54
|
r ? t.items.push({
|
|
54
55
|
...r,
|
|
55
56
|
line: n
|
|
@@ -61,10 +62,10 @@ function s(e) {
|
|
|
61
62
|
}
|
|
62
63
|
//#endregion
|
|
63
64
|
//#region ../../extensions/maps/src/attribution-text.ts
|
|
64
|
-
function
|
|
65
|
-
return e.replace(/<!--[\s\S]*?-->/g, "").replace(/<\/?[a-zA-Z][^>]*>/g, "").replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[a-zA-Z]+);/g, (e, t) =>
|
|
65
|
+
function l(e) {
|
|
66
|
+
return e.replace(/<!--[\s\S]*?-->/g, "").replace(/<\/?[a-zA-Z][^>]*>/g, "").replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[a-zA-Z]+);/g, (e, t) => d(t) ?? e).replace(/\s+/g, " ").trim();
|
|
66
67
|
}
|
|
67
|
-
var
|
|
68
|
+
var u = {
|
|
68
69
|
amp: "&",
|
|
69
70
|
lt: "<",
|
|
70
71
|
gt: ">",
|
|
@@ -74,29 +75,29 @@ var l = {
|
|
|
74
75
|
copy: "©",
|
|
75
76
|
reg: "®"
|
|
76
77
|
};
|
|
77
|
-
function
|
|
78
|
+
function d(e) {
|
|
78
79
|
if (e.startsWith("#")) {
|
|
79
80
|
let t = e[1] === "x" || e[1] === "X" ? Number.parseInt(e.slice(2), 16) : Number.parseInt(e.slice(1), 10);
|
|
80
81
|
return Number.isInteger(t) && t > 0 && t <= 1114111 ? String.fromCodePoint(t) : void 0;
|
|
81
82
|
}
|
|
82
|
-
return
|
|
83
|
+
return u[e];
|
|
83
84
|
}
|
|
84
85
|
//#endregion
|
|
85
86
|
//#region ../../extensions/maps/src/map-drawing.ts
|
|
86
|
-
var
|
|
87
|
+
var f = {
|
|
87
88
|
center: [0, 20],
|
|
88
89
|
zoom: .8
|
|
89
|
-
},
|
|
90
|
-
function
|
|
90
|
+
}, p = "…";
|
|
91
|
+
function m(e, t, n) {
|
|
91
92
|
if (n(e) <= t) return e;
|
|
92
93
|
let r = Array.from(e);
|
|
93
94
|
for (let e = r.length - 1; e >= 0; e--) {
|
|
94
|
-
let i = `${r.slice(0, e).join("").trimEnd()}${
|
|
95
|
+
let i = `${r.slice(0, e).join("").trimEnd()}${p}`;
|
|
95
96
|
if (n(i) <= t) return i;
|
|
96
97
|
}
|
|
97
98
|
return "";
|
|
98
99
|
}
|
|
99
|
-
function
|
|
100
|
+
function h(e, t) {
|
|
100
101
|
let n = t ? "#0b0d10" : "#ffffff", r = t ? "#7cc4ff" : "#1d5fd1", i = t ? "#ffd166" : "#c2410c", a = {
|
|
101
102
|
"line-cap": "round",
|
|
102
103
|
"line-join": "round"
|
|
@@ -131,7 +132,7 @@ function m(e, t) {
|
|
|
131
132
|
}
|
|
132
133
|
}];
|
|
133
134
|
}
|
|
134
|
-
function
|
|
135
|
+
function g(e) {
|
|
135
136
|
return {
|
|
136
137
|
version: 8,
|
|
137
138
|
sources: {},
|
|
@@ -144,12 +145,12 @@ function h(e) {
|
|
|
144
145
|
}
|
|
145
146
|
//#endregion
|
|
146
147
|
//#region ../../extensions/maps/src/map-geometry.ts
|
|
147
|
-
function
|
|
148
|
+
function _(e) {
|
|
148
149
|
return e.kind === "place" ? [e.point] : e.points;
|
|
149
150
|
}
|
|
150
|
-
function
|
|
151
|
+
function v(e) {
|
|
151
152
|
let t = Infinity, n = -Infinity, r = Infinity, i = -Infinity, a = Infinity, o = -Infinity;
|
|
152
|
-
for (let s of e) for (let { lat: e, lon: c } of
|
|
153
|
+
for (let s of e) for (let { lat: e, lon: c } of _(s)) {
|
|
153
154
|
e < t && (t = e), e > n && (n = e), c < r && (r = c), c > i && (i = c);
|
|
154
155
|
let s = c < 0 ? c + 360 : c;
|
|
155
156
|
s < a && (a = s), s > o && (o = s);
|
|
@@ -166,7 +167,7 @@ function _(e) {
|
|
|
166
167
|
north: n
|
|
167
168
|
};
|
|
168
169
|
}
|
|
169
|
-
function
|
|
170
|
+
function y(e, t, n) {
|
|
170
171
|
let r = Math.min(1, e * .5 / (n.left + n.right)), i = Math.min(1, t * .5 / (n.top + n.bottom));
|
|
171
172
|
return {
|
|
172
173
|
top: n.top * i,
|
|
@@ -175,54 +176,54 @@ function v(e, t, n) {
|
|
|
175
176
|
right: n.right * r
|
|
176
177
|
};
|
|
177
178
|
}
|
|
178
|
-
var
|
|
179
|
+
var b = 2, x = 2e4, S = {
|
|
179
180
|
top: 48,
|
|
180
181
|
bottom: 40,
|
|
181
182
|
left: 40,
|
|
182
183
|
right: 40
|
|
183
|
-
},
|
|
184
|
+
}, C = .4, w = 4, T = "etherpk-picture-routes", E = "M12 31c-1-3-10-12-10-19a10 10 0 0 1 20 0c0 7-9 16-10 19z", D = "system-ui, -apple-system, \"Segoe UI\", sans-serif", O = {
|
|
184
185
|
pin: "#1d5fd1",
|
|
185
186
|
pinEdge: "#ffffff",
|
|
186
187
|
plate: "rgba(255, 255, 255, 0.92)",
|
|
187
188
|
name: "#111827",
|
|
188
189
|
credit: "#374151"
|
|
189
|
-
},
|
|
190
|
+
}, k = {
|
|
190
191
|
pin: "#7cc4ff",
|
|
191
192
|
pinEdge: "#0b0d10",
|
|
192
193
|
plate: "rgba(17, 20, 24, 0.92)",
|
|
193
194
|
name: "#f3f4f6",
|
|
194
195
|
credit: "#d1d5db"
|
|
195
196
|
};
|
|
196
|
-
function
|
|
197
|
+
function A(e) {
|
|
197
198
|
let t = /* @__PURE__ */ new Set();
|
|
198
199
|
for (let n of Object.keys(e.getStyle()?.sources ?? {})) {
|
|
199
200
|
let r = e.getSource(n)?.attribution;
|
|
200
201
|
if (typeof r != "string" || r.trim() === "") continue;
|
|
201
|
-
let i =
|
|
202
|
+
let i = l(r);
|
|
202
203
|
i && t.add(i);
|
|
203
204
|
}
|
|
204
205
|
return [...t].join(" ");
|
|
205
206
|
}
|
|
206
|
-
function
|
|
207
|
+
function j(e, t, n, r) {
|
|
207
208
|
e.save(), e.translate(t - 12, n - 31), e.shadowColor = "rgba(0, 0, 0, 0.35)", e.shadowBlur = 2, e.shadowOffsetY = 1;
|
|
208
|
-
let i = new Path2D(
|
|
209
|
+
let i = new Path2D(E);
|
|
209
210
|
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();
|
|
210
211
|
}
|
|
211
|
-
var
|
|
212
|
-
function
|
|
213
|
-
e.font =
|
|
214
|
-
let o =
|
|
212
|
+
var M = `600 14px ${D}`, N = (e) => 14 + e + 12;
|
|
213
|
+
function P(e, t, n, r, i, a) {
|
|
214
|
+
e.font = M;
|
|
215
|
+
let o = m(r, i - w - N(0) - t, (t) => e.measureText(t).width);
|
|
215
216
|
if (o === "") return;
|
|
216
217
|
let s = e.measureText(o).width, c = t + 14, l = n - 29;
|
|
217
218
|
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);
|
|
218
219
|
}
|
|
219
|
-
function
|
|
220
|
+
function F(e, t, n, r, i) {
|
|
220
221
|
if (t === "") return;
|
|
221
|
-
e.font = `14px ${
|
|
222
|
+
e.font = `14px ${D}`;
|
|
222
223
|
let a = Math.min(e.measureText(t).width, n - 16);
|
|
223
224
|
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);
|
|
224
225
|
}
|
|
225
|
-
async function
|
|
226
|
+
async function I(e) {
|
|
226
227
|
for (let t of ["image/webp", "image/png"]) {
|
|
227
228
|
let n = await new Promise((n) => e.toBlob(n, t, .9));
|
|
228
229
|
if (n && n.type === t) return {
|
|
@@ -232,9 +233,9 @@ async function F(e) {
|
|
|
232
233
|
}
|
|
233
234
|
throw Error("this browser couldn't save the picture");
|
|
234
235
|
}
|
|
235
|
-
function
|
|
236
|
+
function L(e) {
|
|
236
237
|
return new Promise((t, n) => {
|
|
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")),
|
|
238
|
+
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")), x);
|
|
238
239
|
e.on("error", (e) => {
|
|
239
240
|
let t = e;
|
|
240
241
|
if (t.tile !== void 0 || t.sourceId !== void 0) {
|
|
@@ -247,8 +248,8 @@ function I(e) {
|
|
|
247
248
|
});
|
|
248
249
|
});
|
|
249
250
|
}
|
|
250
|
-
async function
|
|
251
|
-
let r = n.width ?? 800, i = n.height ?? 450, a = n.dark ?? !1, o = a ?
|
|
251
|
+
async function R(t, n) {
|
|
252
|
+
let r = n.width ?? 800, i = n.height ?? 450, a = n.dark ?? !1, o = a ? k : O, { items: s } = c(t.split("\n"));
|
|
252
253
|
if (n.style !== null && typeof navigator < "u" && navigator.onLine === !1) throw Error("you're offline, and the map's tiles can't be fetched");
|
|
253
254
|
let l = document.createElement("div");
|
|
254
255
|
l.setAttribute("aria-hidden", "true"), Object.assign(l.style, {
|
|
@@ -264,40 +265,40 @@ async function L(t, n) {
|
|
|
264
265
|
try {
|
|
265
266
|
u = new e({
|
|
266
267
|
container: l,
|
|
267
|
-
style: n.style ??
|
|
268
|
+
style: n.style ?? g(a),
|
|
268
269
|
interactive: !1,
|
|
269
270
|
attributionControl: !1,
|
|
270
271
|
fadeDuration: 0,
|
|
271
|
-
pixelRatio:
|
|
272
|
+
pixelRatio: b,
|
|
272
273
|
canvasContextAttributes: { preserveDrawingBuffer: !0 },
|
|
273
|
-
...
|
|
274
|
+
...f
|
|
274
275
|
});
|
|
275
276
|
} catch {
|
|
276
277
|
throw Error("this browser can't draw maps");
|
|
277
278
|
}
|
|
278
|
-
let t = u,
|
|
279
|
-
|
|
280
|
-
let
|
|
281
|
-
if (!
|
|
282
|
-
let p =
|
|
283
|
-
|
|
284
|
-
let
|
|
285
|
-
if (
|
|
286
|
-
let
|
|
287
|
-
|
|
288
|
-
padding:
|
|
289
|
-
...
|
|
290
|
-
right:
|
|
279
|
+
let t = u, c = document.createElement("canvas");
|
|
280
|
+
c.width = r * b, c.height = i * b;
|
|
281
|
+
let d = c.getContext("2d");
|
|
282
|
+
if (!d) throw Error("this browser can't draw the picture");
|
|
283
|
+
let p = s.filter((e) => e.kind === "place"), m = p.length <= 30;
|
|
284
|
+
d.font = M;
|
|
285
|
+
let _ = 0;
|
|
286
|
+
if (m) for (let e of p) e.name !== "" && (_ = Math.max(_, N(d.measureText(e.name).width)));
|
|
287
|
+
let x = v(s);
|
|
288
|
+
x && t.fitBounds([[x.west, x.south], [x.east, x.north]], {
|
|
289
|
+
padding: y(r, i, {
|
|
290
|
+
...S,
|
|
291
|
+
right: S.right + Math.min(_, r * C)
|
|
291
292
|
}),
|
|
292
293
|
maxZoom: 14,
|
|
293
294
|
animate: !1
|
|
294
295
|
});
|
|
295
|
-
let
|
|
296
|
-
t.addSource(
|
|
296
|
+
let w = L(t), E = () => {
|
|
297
|
+
t.addSource(T, {
|
|
297
298
|
type: "geojson",
|
|
298
299
|
data: {
|
|
299
300
|
type: "FeatureCollection",
|
|
300
|
-
features:
|
|
301
|
+
features: s.flatMap((e) => e.kind === "route" ? [{
|
|
301
302
|
type: "Feature",
|
|
302
303
|
properties: { selected: !1 },
|
|
303
304
|
geometry: {
|
|
@@ -307,15 +308,15 @@ async function L(t, n) {
|
|
|
307
308
|
}] : [])
|
|
308
309
|
}
|
|
309
310
|
});
|
|
310
|
-
for (let e of
|
|
311
|
+
for (let e of h(T, a)) t.addLayer(e);
|
|
311
312
|
};
|
|
312
|
-
t.isStyleLoaded() ? E() : t.once("style.load", E), await
|
|
313
|
+
t.isStyleLoaded() ? E() : t.once("style.load", E), await w, d.drawImage(t.getCanvas(), 0, 0, c.width, c.height), d.scale(b, b);
|
|
313
314
|
for (let e of p) {
|
|
314
315
|
let { x: n, y: i } = t.project([e.point.lon, e.point.lat]);
|
|
315
|
-
|
|
316
|
+
j(d, n, i, o), m && e.name !== "" && P(d, n, i, e.name, r, o);
|
|
316
317
|
}
|
|
317
|
-
return
|
|
318
|
-
...await
|
|
318
|
+
return F(d, A(t), r, i, o), {
|
|
319
|
+
...await I(c),
|
|
319
320
|
width: r,
|
|
320
321
|
height: i
|
|
321
322
|
};
|
|
@@ -323,5 +324,5 @@ async function L(t, n) {
|
|
|
323
324
|
u?.remove(), l.remove();
|
|
324
325
|
}
|
|
325
326
|
}
|
|
326
|
-
t(new URL("/maplibre-gl-worker.mjs", location.href).toString()), window.etherpkDrawMapPicture =
|
|
327
|
+
t(new URL("/maplibre-gl-worker.mjs", location.href).toString()), window.etherpkDrawMapPicture = R;
|
|
327
328
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsoftwareltd/etherpk-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
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.
|
|
48
|
-
"@appsoftwareltd/etherpk-
|
|
49
|
-
"@appsoftwareltd/etherpk-
|
|
50
|
-
"@appsoftwareltd/etherpk-
|
|
47
|
+
"@appsoftwareltd/etherpk-extension-graph-view": "0.10.1",
|
|
48
|
+
"@appsoftwareltd/etherpk-shared": "0.10.1",
|
|
49
|
+
"@appsoftwareltd/etherpk-extension-maps": "0.10.1",
|
|
50
|
+
"@appsoftwareltd/etherpk-themes": "0.10.1"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|