@appsoftwareltd/etherpk-mcp 0.9.5 → 0.10.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.
@@ -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 i(e) {
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 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);
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 = i(e);
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 o(e) {
36
+ function s(e) {
37
37
  let t = e.trim();
38
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());
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 a(t, "");
44
+ return o(t, "");
44
45
  }
45
- function s(e) {
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 = o(e);
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 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();
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 l = {
68
+ var u = {
68
69
  amp: "&",
69
70
  lt: "<",
70
71
  gt: ">",
@@ -74,16 +75,29 @@ var l = {
74
75
  copy: "©",
75
76
  reg: "®"
76
77
  };
77
- function u(e) {
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 l[e];
83
+ return u[e];
83
84
  }
84
85
  //#endregion
85
86
  //#region ../../extensions/maps/src/map-drawing.ts
86
- function d(e, t) {
87
+ var f = {
88
+ center: [0, 20],
89
+ zoom: .8
90
+ }, p = "…";
91
+ function m(e, t, n) {
92
+ if (n(e) <= t) return e;
93
+ let r = Array.from(e);
94
+ for (let e = r.length - 1; e >= 0; e--) {
95
+ let i = `${r.slice(0, e).join("").trimEnd()}${p}`;
96
+ if (n(i) <= t) return i;
97
+ }
98
+ return "";
99
+ }
100
+ function h(e, t) {
87
101
  let n = t ? "#0b0d10" : "#ffffff", r = t ? "#7cc4ff" : "#1d5fd1", i = t ? "#ffd166" : "#c2410c", a = {
88
102
  "line-cap": "round",
89
103
  "line-join": "round"
@@ -118,7 +132,7 @@ function d(e, t) {
118
132
  }
119
133
  }];
120
134
  }
121
- function f(e) {
135
+ function g(e) {
122
136
  return {
123
137
  version: 8,
124
138
  sources: {},
@@ -131,12 +145,12 @@ function f(e) {
131
145
  }
132
146
  //#endregion
133
147
  //#region ../../extensions/maps/src/map-geometry.ts
134
- function p(e) {
148
+ function _(e) {
135
149
  return e.kind === "place" ? [e.point] : e.points;
136
150
  }
137
- function m(e) {
151
+ function v(e) {
138
152
  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)) {
153
+ for (let s of e) for (let { lat: e, lon: c } of _(s)) {
140
154
  e < t && (t = e), e > n && (n = e), c < r && (r = c), c > i && (i = c);
141
155
  let s = c < 0 ? c + 360 : c;
142
156
  s < a && (a = s), s > o && (o = s);
@@ -153,40 +167,63 @@ function m(e) {
153
167
  north: n
154
168
  };
155
169
  }
156
- var h = 2, g = 2e4, _ = {
170
+ function y(e, t, n) {
171
+ let r = Math.min(1, e * .5 / (n.left + n.right)), i = Math.min(1, t * .5 / (n.top + n.bottom));
172
+ return {
173
+ top: n.top * i,
174
+ bottom: n.bottom * i,
175
+ left: n.left * r,
176
+ right: n.right * r
177
+ };
178
+ }
179
+ var b = 2, x = 2e4, S = {
157
180
  top: 48,
158
181
  bottom: 40,
159
182
  left: 40,
160
183
  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) {
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 = {
185
+ pin: "#1d5fd1",
186
+ pinEdge: "#ffffff",
187
+ plate: "rgba(255, 255, 255, 0.92)",
188
+ name: "#111827",
189
+ credit: "#374151"
190
+ }, k = {
191
+ pin: "#7cc4ff",
192
+ pinEdge: "#0b0d10",
193
+ plate: "rgba(17, 20, 24, 0.92)",
194
+ name: "#f3f4f6",
195
+ credit: "#d1d5db"
196
+ };
197
+ function A(e) {
163
198
  let t = /* @__PURE__ */ new Set();
164
199
  for (let n of Object.keys(e.getStyle()?.sources ?? {})) {
165
200
  let r = e.getSource(n)?.attribution;
166
201
  if (typeof r != "string" || r.trim() === "") continue;
167
- let i = c(r);
202
+ let i = l(r);
168
203
  i && t.add(i);
169
204
  }
170
205
  return [...t].join(" ");
171
206
  }
172
- function w(e, t, n) {
207
+ function j(e, t, n, r) {
173
208
  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();
209
+ let i = new Path2D(E);
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();
176
211
  }
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);
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);
216
+ if (o === "") return;
217
+ let s = e.measureText(o).width, c = t + 14, l = n - 29;
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);
182
219
  }
183
- function O(e, t) {
220
+ function F(e, t, n, r, i) {
184
221
  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);
222
+ e.font = `14px ${D}`;
223
+ let a = Math.min(e.measureText(t).width, n - 16);
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);
188
225
  }
189
- async function k(e) {
226
+ async function I(e) {
190
227
  for (let t of ["image/webp", "image/png"]) {
191
228
  let n = await new Promise((n) => e.toBlob(n, t, .9));
192
229
  if (n && n.type === t) return {
@@ -196,9 +233,9 @@ async function k(e) {
196
233
  }
197
234
  throw Error("this browser couldn't save the picture");
198
235
  }
199
- function A(e) {
236
+ function L(e) {
200
237
  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);
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);
202
239
  e.on("error", (e) => {
203
240
  let t = e;
204
241
  if (t.tile !== void 0 || t.sourceId !== void 0) {
@@ -211,58 +248,57 @@ function A(e) {
211
248
  });
212
249
  });
213
250
  }
214
- async function j(t, n) {
215
- let { items: r } = s(t.split("\n"));
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"));
216
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");
217
- let i = document.createElement("div");
218
- i.setAttribute("aria-hidden", "true"), Object.assign(i.style, {
254
+ let l = document.createElement("div");
255
+ l.setAttribute("aria-hidden", "true"), Object.assign(l.style, {
219
256
  position: "fixed",
220
257
  left: "-10000px",
221
258
  top: "0",
222
- width: "800px",
223
- height: "450px",
259
+ width: `${r}px`,
260
+ height: `${i}px`,
224
261
  pointerEvents: "none"
225
- }), document.body.appendChild(i);
226
- let a = null;
262
+ }), document.body.appendChild(l);
263
+ let u = null;
227
264
  try {
228
265
  try {
229
- a = new e({
230
- container: i,
231
- style: n.style ?? f(!1),
266
+ u = new e({
267
+ container: l,
268
+ style: n.style ?? g(a),
232
269
  interactive: !1,
233
270
  attributionControl: !1,
234
271
  fadeDuration: 0,
235
- pixelRatio: h,
272
+ pixelRatio: b,
236
273
  canvasContextAttributes: { preserveDrawingBuffer: !0 },
237
- center: [0, 20],
238
- zoom: .8
274
+ ...f
239
275
  });
240
276
  } catch {
241
277
  throw Error("this browser can't draw maps");
242
278
  }
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
- },
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)
292
+ }),
257
293
  maxZoom: 14,
258
294
  animate: !1
259
295
  });
260
- let g = A(t), b = () => {
261
- t.addSource(y, {
296
+ let w = L(t), E = () => {
297
+ t.addSource(T, {
262
298
  type: "geojson",
263
299
  data: {
264
300
  type: "FeatureCollection",
265
- features: r.flatMap((e) => e.kind === "route" ? [{
301
+ features: s.flatMap((e) => e.kind === "route" ? [{
266
302
  type: "Feature",
267
303
  properties: { selected: !1 },
268
304
  geometry: {
@@ -272,21 +308,21 @@ async function j(t, n) {
272
308
  }] : [])
273
309
  }
274
310
  });
275
- for (let e of d(y, !1)) t.addLayer(e);
311
+ for (let e of h(T, a)) t.addLayer(e);
276
312
  };
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);
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);
314
+ for (let e of p) {
315
+ let { x: n, y: i } = t.project([e.point.lon, e.point.lat]);
316
+ j(d, n, i, o), m && e.name !== "" && P(d, n, i, e.name, r, o);
281
317
  }
282
- return O(s, C(t)), {
283
- ...await k(o),
284
- width: 800,
285
- height: 450
318
+ return F(d, A(t), r, i, o), {
319
+ ...await I(c),
320
+ width: r,
321
+ height: i
286
322
  };
287
323
  } finally {
288
- a?.remove(), i.remove();
324
+ u?.remove(), l.remove();
289
325
  }
290
326
  }
291
- t(new URL("/maplibre-gl-worker.mjs", location.href).toString()), window.etherpkDrawMapPicture = j;
327
+ t(new URL("/maplibre-gl-worker.mjs", location.href).toString()), window.etherpkDrawMapPicture = R;
292
328
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsoftwareltd/etherpk-mcp",
3
- "version": "0.9.5",
3
+ "version": "0.10.0",
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.5",
48
- "@appsoftwareltd/etherpk-extension-maps": "0.9.5",
49
- "@appsoftwareltd/etherpk-themes": "0.9.5",
50
- "@appsoftwareltd/etherpk-shared": "0.9.5"
47
+ "@appsoftwareltd/etherpk-extension-graph-view": "0.10.0",
48
+ "@appsoftwareltd/etherpk-extension-maps": "0.10.0",
49
+ "@appsoftwareltd/etherpk-shared": "0.10.0",
50
+ "@appsoftwareltd/etherpk-themes": "0.10.0"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"