@appsoftwareltd/etherpk-mcp 0.9.3 → 0.9.5
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 +8 -5
- package/dist/main.js +713 -96
- package/dist/main.js.map +1 -1
- package/dist/map-picture-page.js +292 -0
- package/package.json +9 -6
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { Map as e, setWorkerUrl as t } from "maplibre-gl";
|
|
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 i(e) {
|
|
5
|
+
let t = r.exec(e);
|
|
6
|
+
if (!t) return null;
|
|
7
|
+
let n = Number(t[1]), i = Number(t[2]);
|
|
8
|
+
return !Number.isFinite(n) || !Number.isFinite(i) || n < -90 || n > 90 || i < -180 || i > 180 ? null : {
|
|
9
|
+
lat: n,
|
|
10
|
+
lon: i
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function a(e, t) {
|
|
14
|
+
let n = e.trim(), r = null, a = n.indexOf("(");
|
|
15
|
+
if (a >= 0) {
|
|
16
|
+
if (!n.endsWith(")") || (r = n.slice(a + 1, -1).trim(), r === "")) return null;
|
|
17
|
+
n = n.slice(0, a);
|
|
18
|
+
}
|
|
19
|
+
let o = [];
|
|
20
|
+
for (let e of n.split(">")) {
|
|
21
|
+
let t = i(e);
|
|
22
|
+
if (!t) return null;
|
|
23
|
+
o.push(t);
|
|
24
|
+
}
|
|
25
|
+
return o.length === 1 ? r === null ? {
|
|
26
|
+
kind: "place",
|
|
27
|
+
name: t,
|
|
28
|
+
point: o[0]
|
|
29
|
+
} : null : {
|
|
30
|
+
kind: "route",
|
|
31
|
+
name: t,
|
|
32
|
+
points: o,
|
|
33
|
+
track: r
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function o(e) {
|
|
37
|
+
let t = e.trim();
|
|
38
|
+
if (t === "") return null;
|
|
39
|
+
for (let e = t.lastIndexOf("@"); e >= 0; e = e === 0 ? -1 : t.lastIndexOf("@", e - 1)) {
|
|
40
|
+
let n = a(t.slice(e + 1), t.slice(0, e).trim());
|
|
41
|
+
if (n) return n;
|
|
42
|
+
}
|
|
43
|
+
return a(t, "");
|
|
44
|
+
}
|
|
45
|
+
function s(e) {
|
|
46
|
+
let t = {
|
|
47
|
+
items: [],
|
|
48
|
+
unread: []
|
|
49
|
+
};
|
|
50
|
+
return e.forEach((e, n) => {
|
|
51
|
+
if (e.trim() === "") return;
|
|
52
|
+
let r = o(e);
|
|
53
|
+
r ? t.items.push({
|
|
54
|
+
...r,
|
|
55
|
+
line: n
|
|
56
|
+
}) : t.unread.push({
|
|
57
|
+
line: n,
|
|
58
|
+
text: e
|
|
59
|
+
});
|
|
60
|
+
}), t;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region ../../extensions/maps/src/attribution-text.ts
|
|
64
|
+
function c(e) {
|
|
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) => u(t) ?? e).replace(/\s+/g, " ").trim();
|
|
66
|
+
}
|
|
67
|
+
var l = {
|
|
68
|
+
amp: "&",
|
|
69
|
+
lt: "<",
|
|
70
|
+
gt: ">",
|
|
71
|
+
quot: "\"",
|
|
72
|
+
apos: "'",
|
|
73
|
+
nbsp: " ",
|
|
74
|
+
copy: "©",
|
|
75
|
+
reg: "®"
|
|
76
|
+
};
|
|
77
|
+
function u(e) {
|
|
78
|
+
if (e.startsWith("#")) {
|
|
79
|
+
let t = e[1] === "x" || e[1] === "X" ? Number.parseInt(e.slice(2), 16) : Number.parseInt(e.slice(1), 10);
|
|
80
|
+
return Number.isInteger(t) && t > 0 && t <= 1114111 ? String.fromCodePoint(t) : void 0;
|
|
81
|
+
}
|
|
82
|
+
return l[e];
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region ../../extensions/maps/src/map-drawing.ts
|
|
86
|
+
function d(e, t) {
|
|
87
|
+
let n = t ? "#0b0d10" : "#ffffff", r = t ? "#7cc4ff" : "#1d5fd1", i = t ? "#ffd166" : "#c2410c", a = {
|
|
88
|
+
"line-cap": "round",
|
|
89
|
+
"line-join": "round"
|
|
90
|
+
};
|
|
91
|
+
return [{
|
|
92
|
+
id: `${e}-casing`,
|
|
93
|
+
type: "line",
|
|
94
|
+
source: e,
|
|
95
|
+
layout: a,
|
|
96
|
+
paint: {
|
|
97
|
+
"line-color": n,
|
|
98
|
+
"line-width": 7,
|
|
99
|
+
"line-opacity": .9
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
id: `${e}-line`,
|
|
103
|
+
type: "line",
|
|
104
|
+
source: e,
|
|
105
|
+
layout: a,
|
|
106
|
+
paint: {
|
|
107
|
+
"line-color": [
|
|
108
|
+
"case",
|
|
109
|
+
[
|
|
110
|
+
"==",
|
|
111
|
+
["get", "selected"],
|
|
112
|
+
!0
|
|
113
|
+
],
|
|
114
|
+
i,
|
|
115
|
+
r
|
|
116
|
+
],
|
|
117
|
+
"line-width": 4
|
|
118
|
+
}
|
|
119
|
+
}];
|
|
120
|
+
}
|
|
121
|
+
function f(e) {
|
|
122
|
+
return {
|
|
123
|
+
version: 8,
|
|
124
|
+
sources: {},
|
|
125
|
+
layers: [{
|
|
126
|
+
id: "background",
|
|
127
|
+
type: "background",
|
|
128
|
+
paint: { "background-color": e ? "#1f2329" : "#e8ecef" }
|
|
129
|
+
}]
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region ../../extensions/maps/src/map-geometry.ts
|
|
134
|
+
function p(e) {
|
|
135
|
+
return e.kind === "place" ? [e.point] : e.points;
|
|
136
|
+
}
|
|
137
|
+
function m(e) {
|
|
138
|
+
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 p(s)) {
|
|
140
|
+
e < t && (t = e), e > n && (n = e), c < r && (r = c), c > i && (i = c);
|
|
141
|
+
let s = c < 0 ? c + 360 : c;
|
|
142
|
+
s < a && (a = s), s > o && (o = s);
|
|
143
|
+
}
|
|
144
|
+
return t === Infinity ? null : o - a < i - r ? {
|
|
145
|
+
west: a,
|
|
146
|
+
south: t,
|
|
147
|
+
east: o,
|
|
148
|
+
north: n
|
|
149
|
+
} : {
|
|
150
|
+
west: r,
|
|
151
|
+
south: t,
|
|
152
|
+
east: i,
|
|
153
|
+
north: n
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
var h = 2, g = 2e4, _ = {
|
|
157
|
+
top: 48,
|
|
158
|
+
bottom: 40,
|
|
159
|
+
left: 40,
|
|
160
|
+
right: 40
|
|
161
|
+
}, v = .4, y = "etherpk-picture-routes", b = "M12 31c-1-3-10-12-10-19a10 10 0 0 1 20 0c0 7-9 16-10 19z", x = "#1d5fd1", S = "system-ui, -apple-system, \"Segoe UI\", sans-serif";
|
|
162
|
+
function C(e) {
|
|
163
|
+
let t = /* @__PURE__ */ new Set();
|
|
164
|
+
for (let n of Object.keys(e.getStyle()?.sources ?? {})) {
|
|
165
|
+
let r = e.getSource(n)?.attribution;
|
|
166
|
+
if (typeof r != "string" || r.trim() === "") continue;
|
|
167
|
+
let i = c(r);
|
|
168
|
+
i && t.add(i);
|
|
169
|
+
}
|
|
170
|
+
return [...t].join(" ");
|
|
171
|
+
}
|
|
172
|
+
function w(e, t, n) {
|
|
173
|
+
e.save(), e.translate(t - 12, n - 31), e.shadowColor = "rgba(0, 0, 0, 0.35)", e.shadowBlur = 2, e.shadowOffsetY = 1;
|
|
174
|
+
let r = new Path2D(b);
|
|
175
|
+
e.fillStyle = x, e.fill(r), e.shadowColor = "transparent", e.lineWidth = 1.5, e.strokeStyle = "#ffffff", e.stroke(r), e.beginPath(), e.arc(12, 12, 4, 0, Math.PI * 2), e.fillStyle = "#ffffff", e.fill(), e.restore();
|
|
176
|
+
}
|
|
177
|
+
var T = `600 14px ${S}`, E = (e) => 14 + e + 12;
|
|
178
|
+
function D(e, t, n, r) {
|
|
179
|
+
e.font = T;
|
|
180
|
+
let i = e.measureText(r).width, a = t + 14, o = n - 29;
|
|
181
|
+
e.fillStyle = "rgba(255, 255, 255, 0.92)", e.beginPath(), e.roundRect(a, o, i + 12, 20, 4), e.fill(), e.fillStyle = "#111827", e.textBaseline = "middle", e.fillText(r, a + 6, o + 10);
|
|
182
|
+
}
|
|
183
|
+
function O(e, t) {
|
|
184
|
+
if (t === "") return;
|
|
185
|
+
e.font = `14px ${S}`;
|
|
186
|
+
let n = Math.min(e.measureText(t).width, 784);
|
|
187
|
+
e.fillStyle = "rgba(255, 255, 255, 0.9)", e.fillRect(800 - n - 12, 426, n + 12, 24), e.fillStyle = "#374151", e.textBaseline = "middle", e.fillText(t, 800 - n - 6, 438, n);
|
|
188
|
+
}
|
|
189
|
+
async function k(e) {
|
|
190
|
+
for (let t of ["image/webp", "image/png"]) {
|
|
191
|
+
let n = await new Promise((n) => e.toBlob(n, t, .9));
|
|
192
|
+
if (n && n.type === t) return {
|
|
193
|
+
bytes: new Uint8Array(await n.arrayBuffer()),
|
|
194
|
+
type: t
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
throw Error("this browser couldn't save the picture");
|
|
198
|
+
}
|
|
199
|
+
function A(e) {
|
|
200
|
+
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")), g);
|
|
202
|
+
e.on("error", (e) => {
|
|
203
|
+
let t = e;
|
|
204
|
+
if (t.tile !== void 0 || t.sourceId !== void 0) {
|
|
205
|
+
r++;
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
clearTimeout(i), n(/* @__PURE__ */ Error("the map's style couldn't be loaded"));
|
|
209
|
+
}), e.once("idle", () => {
|
|
210
|
+
clearTimeout(i), r > 0 ? n(/* @__PURE__ */ Error("some of the map's tiles didn't load. Check your connection, then try again")) : t();
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
async function j(t, n) {
|
|
215
|
+
let { items: r } = s(t.split("\n"));
|
|
216
|
+
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 i = document.createElement("div");
|
|
218
|
+
i.setAttribute("aria-hidden", "true"), Object.assign(i.style, {
|
|
219
|
+
position: "fixed",
|
|
220
|
+
left: "-10000px",
|
|
221
|
+
top: "0",
|
|
222
|
+
width: "800px",
|
|
223
|
+
height: "450px",
|
|
224
|
+
pointerEvents: "none"
|
|
225
|
+
}), document.body.appendChild(i);
|
|
226
|
+
let a = null;
|
|
227
|
+
try {
|
|
228
|
+
try {
|
|
229
|
+
a = new e({
|
|
230
|
+
container: i,
|
|
231
|
+
style: n.style ?? f(!1),
|
|
232
|
+
interactive: !1,
|
|
233
|
+
attributionControl: !1,
|
|
234
|
+
fadeDuration: 0,
|
|
235
|
+
pixelRatio: h,
|
|
236
|
+
canvasContextAttributes: { preserveDrawingBuffer: !0 },
|
|
237
|
+
center: [0, 20],
|
|
238
|
+
zoom: .8
|
|
239
|
+
});
|
|
240
|
+
} catch {
|
|
241
|
+
throw Error("this browser can't draw maps");
|
|
242
|
+
}
|
|
243
|
+
let t = a, o = document.createElement("canvas");
|
|
244
|
+
o.width = 800 * h, o.height = 450 * h;
|
|
245
|
+
let s = o.getContext("2d");
|
|
246
|
+
if (!s) throw Error("this browser can't draw the picture");
|
|
247
|
+
let c = r.filter((e) => e.kind === "place"), l = c.length <= 30;
|
|
248
|
+
s.font = T;
|
|
249
|
+
let u = 0;
|
|
250
|
+
if (l) for (let e of c) e.name !== "" && (u = Math.max(u, E(s.measureText(e.name).width)));
|
|
251
|
+
let p = m(r);
|
|
252
|
+
p && t.fitBounds([[p.west, p.south], [p.east, p.north]], {
|
|
253
|
+
padding: {
|
|
254
|
+
..._,
|
|
255
|
+
right: _.right + Math.min(u, 800 * v)
|
|
256
|
+
},
|
|
257
|
+
maxZoom: 14,
|
|
258
|
+
animate: !1
|
|
259
|
+
});
|
|
260
|
+
let g = A(t), b = () => {
|
|
261
|
+
t.addSource(y, {
|
|
262
|
+
type: "geojson",
|
|
263
|
+
data: {
|
|
264
|
+
type: "FeatureCollection",
|
|
265
|
+
features: r.flatMap((e) => e.kind === "route" ? [{
|
|
266
|
+
type: "Feature",
|
|
267
|
+
properties: { selected: !1 },
|
|
268
|
+
geometry: {
|
|
269
|
+
type: "LineString",
|
|
270
|
+
coordinates: e.points.map((e) => [e.lon, e.lat])
|
|
271
|
+
}
|
|
272
|
+
}] : [])
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
for (let e of d(y, !1)) t.addLayer(e);
|
|
276
|
+
};
|
|
277
|
+
t.isStyleLoaded() ? b() : t.once("style.load", b), await g, s.drawImage(t.getCanvas(), 0, 0, o.width, o.height), s.scale(h, h);
|
|
278
|
+
for (let e of c) {
|
|
279
|
+
let { x: n, y: r } = t.project([e.point.lon, e.point.lat]);
|
|
280
|
+
w(s, n, r), l && e.name !== "" && D(s, n, r, e.name);
|
|
281
|
+
}
|
|
282
|
+
return O(s, C(t)), {
|
|
283
|
+
...await k(o),
|
|
284
|
+
width: 800,
|
|
285
|
+
height: 450
|
|
286
|
+
};
|
|
287
|
+
} finally {
|
|
288
|
+
a?.remove(), i.remove();
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
t(new URL("/maplibre-gl-worker.mjs", location.href).toString()), window.etherpkDrawMapPicture = j;
|
|
292
|
+
//#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.5",
|
|
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",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@huggingface/tokenizers": "0.2.0",
|
|
19
19
|
"@lezer/highlight": "^1.2.3",
|
|
20
20
|
"@lezer/markdown": "^1.6.4",
|
|
21
|
-
"@modelcontextprotocol/sdk": "1.
|
|
21
|
+
"@modelcontextprotocol/sdk": "1.31.0",
|
|
22
22
|
"@noble/curves": "2.2.0",
|
|
23
23
|
"@noble/hashes": "2.2.0",
|
|
24
24
|
"@sqlite.org/sqlite-wasm": "3.53.0-build1",
|
|
@@ -26,8 +26,9 @@
|
|
|
26
26
|
"graphology": "^0.26.0",
|
|
27
27
|
"graphology-communities-louvain": "^2.0.2",
|
|
28
28
|
"graphology-types": "^0.24.8",
|
|
29
|
-
"katex": "^0.
|
|
29
|
+
"katex": "^0.18.2",
|
|
30
30
|
"lib0": "0.2.117",
|
|
31
|
+
"maplibre-gl": "6.11.2",
|
|
31
32
|
"markdown-it": "15.0.2",
|
|
32
33
|
"mermaid": "^11.16.1",
|
|
33
34
|
"mustache": "4.2.0",
|
|
@@ -43,8 +44,10 @@
|
|
|
43
44
|
"typescript": "^6.0.2",
|
|
44
45
|
"vite": "^8.0.16",
|
|
45
46
|
"vitest": "^4.1.11",
|
|
46
|
-
"@appsoftwareltd/etherpk-
|
|
47
|
-
"@appsoftwareltd/etherpk-
|
|
47
|
+
"@appsoftwareltd/etherpk-extension-graph-view": "0.9.5",
|
|
48
|
+
"@appsoftwareltd/etherpk-extension-maps": "0.9.5",
|
|
49
|
+
"@appsoftwareltd/etherpk-themes": "0.9.5",
|
|
50
|
+
"@appsoftwareltd/etherpk-shared": "0.9.5"
|
|
48
51
|
},
|
|
49
52
|
"publishConfig": {
|
|
50
53
|
"access": "public"
|
|
@@ -68,7 +71,7 @@
|
|
|
68
71
|
},
|
|
69
72
|
"scripts": {
|
|
70
73
|
"client-tsconfig": "pnpm --dir ../client exec svelte-kit sync",
|
|
71
|
-
"build": "pnpm client-tsconfig && vite build",
|
|
74
|
+
"build": "pnpm client-tsconfig && vite build && vite build --config vite.map-page.config.ts",
|
|
72
75
|
"check": "tsc -p tsconfig.json --noEmit",
|
|
73
76
|
"test": "pnpm client-tsconfig && vitest run",
|
|
74
77
|
"test:watch": "pnpm client-tsconfig && vitest"
|