@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.cjs +23 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -88,7 +88,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
88
88
|
|
|
89
89
|
// src/support/version.ts
|
|
90
90
|
var LIBRARY_NAME = "nodedreame";
|
|
91
|
-
var LIBRARY_VERSION = "1.11.
|
|
91
|
+
var LIBRARY_VERSION = "1.11.10";
|
|
92
92
|
|
|
93
93
|
// src/transport/errors.ts
|
|
94
94
|
var DreameError = class extends Error {
|
|
@@ -4951,11 +4951,15 @@ var DEFAULT_HEIGHT = 1200;
|
|
|
4951
4951
|
var DEFAULT_PADDING = 50;
|
|
4952
4952
|
var BACKGROUND = "#f5f5f0";
|
|
4953
4953
|
var MAP_BOUNDARY = "#006400";
|
|
4954
|
-
var MOWING_PATH = "#
|
|
4954
|
+
var MOWING_PATH = "#32cd32";
|
|
4955
4955
|
var NAV_PATH = "#b4b4b4";
|
|
4956
4956
|
var OBSTACLE_STROKE = "#ff4d00";
|
|
4957
4957
|
var OBSTACLE_FILL = "#ff4d0065";
|
|
4958
4958
|
var TEXT_COLOR = "#000000";
|
|
4959
|
+
var ZONE_LABEL_COLOR = "#3c3c3c";
|
|
4960
|
+
function escapeXml(s) {
|
|
4961
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
4962
|
+
}
|
|
4959
4963
|
var ZONE_COLORS = [
|
|
4960
4964
|
["#a4d291c8", "#86be73"],
|
|
4961
4965
|
["#a0c8dcc8", "#82aac8"],
|
|
@@ -5078,7 +5082,6 @@ function renderMowerSvg(map, opts = {}) {
|
|
|
5078
5082
|
return lines.join("\n");
|
|
5079
5083
|
}
|
|
5080
5084
|
const bounds = calculateBounds(allPoints);
|
|
5081
|
-
const multiZone = map.zones.length > 1;
|
|
5082
5085
|
for (const navPath of map.paths) {
|
|
5083
5086
|
const dashed = svgPathFromSegments(
|
|
5084
5087
|
[navPath.path],
|
|
@@ -5095,9 +5098,6 @@ function renderMowerSvg(map, opts = {}) {
|
|
|
5095
5098
|
}
|
|
5096
5099
|
}
|
|
5097
5100
|
map.zones.forEach((zone, i) => {
|
|
5098
|
-
if (!multiZone) {
|
|
5099
|
-
return;
|
|
5100
|
-
}
|
|
5101
5101
|
const palette = ZONE_COLORS[i % ZONE_COLORS.length];
|
|
5102
5102
|
const [fill, outline] = palette ?? ZONE_COLORS[0] ?? ["#cccccc", "#888888"];
|
|
5103
5103
|
const poly = svgPolygon(zone.path, bounds, width, height, padding, fill, outline);
|
|
@@ -5106,7 +5106,7 @@ function renderMowerSvg(map, opts = {}) {
|
|
|
5106
5106
|
}
|
|
5107
5107
|
});
|
|
5108
5108
|
map.zones.forEach((zone, i) => {
|
|
5109
|
-
const outline =
|
|
5109
|
+
const outline = ZONE_COLORS[i % ZONE_COLORS.length]?.[1] ?? MAP_BOUNDARY;
|
|
5110
5110
|
const boundary = svgPathFromSegments(
|
|
5111
5111
|
[zone.path],
|
|
5112
5112
|
bounds,
|
|
@@ -5150,6 +5150,22 @@ function renderMowerSvg(map, opts = {}) {
|
|
|
5150
5150
|
lines.push(poly);
|
|
5151
5151
|
}
|
|
5152
5152
|
}
|
|
5153
|
+
for (const zone of map.zones) {
|
|
5154
|
+
if (zone.name.length === 0 || zone.path.length === 0) {
|
|
5155
|
+
continue;
|
|
5156
|
+
}
|
|
5157
|
+
let sumX = 0;
|
|
5158
|
+
let sumY = 0;
|
|
5159
|
+
for (const p of zone.path) {
|
|
5160
|
+
sumX += p.x;
|
|
5161
|
+
sumY += p.y;
|
|
5162
|
+
}
|
|
5163
|
+
const centroid = { x: sumX / zone.path.length, y: sumY / zone.path.length };
|
|
5164
|
+
const { px, py } = coordToPixel(centroid, bounds, width, height, padding);
|
|
5165
|
+
lines.push(
|
|
5166
|
+
`<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>`
|
|
5167
|
+
);
|
|
5168
|
+
}
|
|
5153
5169
|
lines.push("</svg>");
|
|
5154
5170
|
return lines.join("\n");
|
|
5155
5171
|
}
|