@apocaliss92/nodedreame 1.11.9 → 1.11.10

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/support/version.ts
2
2
  var LIBRARY_NAME = "nodedreame";
3
- var LIBRARY_VERSION = "1.11.9";
3
+ var LIBRARY_VERSION = "1.11.10";
4
4
 
5
5
  // src/transport/errors.ts
6
6
  var DreameError = class extends Error {
@@ -4863,11 +4863,15 @@ var DEFAULT_HEIGHT = 1200;
4863
4863
  var DEFAULT_PADDING = 50;
4864
4864
  var BACKGROUND = "#f5f5f0";
4865
4865
  var MAP_BOUNDARY = "#006400";
4866
- var MOWING_PATH = "#ffa500";
4866
+ var MOWING_PATH = "#32cd32";
4867
4867
  var NAV_PATH = "#b4b4b4";
4868
4868
  var OBSTACLE_STROKE = "#ff4d00";
4869
4869
  var OBSTACLE_FILL = "#ff4d0065";
4870
4870
  var TEXT_COLOR = "#000000";
4871
+ var ZONE_LABEL_COLOR = "#3c3c3c";
4872
+ function escapeXml(s) {
4873
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
4874
+ }
4871
4875
  var ZONE_COLORS = [
4872
4876
  ["#a4d291c8", "#86be73"],
4873
4877
  ["#a0c8dcc8", "#82aac8"],
@@ -4990,7 +4994,6 @@ function renderMowerSvg(map, opts = {}) {
4990
4994
  return lines.join("\n");
4991
4995
  }
4992
4996
  const bounds = calculateBounds(allPoints);
4993
- const multiZone = map.zones.length > 1;
4994
4997
  for (const navPath of map.paths) {
4995
4998
  const dashed = svgPathFromSegments(
4996
4999
  [navPath.path],
@@ -5007,9 +5010,6 @@ function renderMowerSvg(map, opts = {}) {
5007
5010
  }
5008
5011
  }
5009
5012
  map.zones.forEach((zone, i) => {
5010
- if (!multiZone) {
5011
- return;
5012
- }
5013
5013
  const palette = ZONE_COLORS[i % ZONE_COLORS.length];
5014
5014
  const [fill, outline] = palette ?? ZONE_COLORS[0] ?? ["#cccccc", "#888888"];
5015
5015
  const poly = svgPolygon(zone.path, bounds, width, height, padding, fill, outline);
@@ -5018,7 +5018,7 @@ function renderMowerSvg(map, opts = {}) {
5018
5018
  }
5019
5019
  });
5020
5020
  map.zones.forEach((zone, i) => {
5021
- const outline = multiZone ? ZONE_COLORS[i % ZONE_COLORS.length]?.[1] ?? MAP_BOUNDARY : MAP_BOUNDARY;
5021
+ const outline = ZONE_COLORS[i % ZONE_COLORS.length]?.[1] ?? MAP_BOUNDARY;
5022
5022
  const boundary = svgPathFromSegments(
5023
5023
  [zone.path],
5024
5024
  bounds,
@@ -5062,6 +5062,22 @@ function renderMowerSvg(map, opts = {}) {
5062
5062
  lines.push(poly);
5063
5063
  }
5064
5064
  }
5065
+ for (const zone of map.zones) {
5066
+ if (zone.name.length === 0 || zone.path.length === 0) {
5067
+ continue;
5068
+ }
5069
+ let sumX = 0;
5070
+ let sumY = 0;
5071
+ for (const p of zone.path) {
5072
+ sumX += p.x;
5073
+ sumY += p.y;
5074
+ }
5075
+ const centroid = { x: sumX / zone.path.length, y: sumY / zone.path.length };
5076
+ const { px, py } = coordToPixel(centroid, bounds, width, height, padding);
5077
+ lines.push(
5078
+ `<text x="${px}" y="${py}" font-family="Arial, sans-serif" font-size="20" font-weight="bold" fill="${ZONE_LABEL_COLOR}" text-anchor="middle" dominant-baseline="middle">${escapeXml(zone.name)}</text>`
5079
+ );
5080
+ }
5065
5081
  lines.push("</svg>");
5066
5082
  return lines.join("\n");
5067
5083
  }