@mapmap/maps 0.5.1 → 0.5.2
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 +19 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3936,6 +3936,16 @@ var AdrCheck = class {
|
|
|
3936
3936
|
};
|
|
3937
3937
|
|
|
3938
3938
|
// src/guidance.ts
|
|
3939
|
+
var CSS_COLOUR = /^(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix|var)\((?:[\w\s.,%/#-]|\([\w\s.,%/#-]*\))*\)$/i;
|
|
3940
|
+
function safeColour(value, fallback) {
|
|
3941
|
+
const v = value.trim();
|
|
3942
|
+
if (v === "" || /[;{}]|url\(|\/\*/i.test(v)) return fallback;
|
|
3943
|
+
if (v.startsWith("#")) {
|
|
3944
|
+
return /^[0-9a-fA-F]+$/.test(v.slice(1)) && [3, 4, 6, 8].includes(v.length - 1) ? v : fallback;
|
|
3945
|
+
}
|
|
3946
|
+
if (/^[a-zA-Z][a-zA-Z-]*$/.test(v)) return v;
|
|
3947
|
+
return CSS_COLOUR.test(v) ? v : fallback;
|
|
3948
|
+
}
|
|
3939
3949
|
function extractGuidance(route) {
|
|
3940
3950
|
const legs = route.raw["legs"] ?? [];
|
|
3941
3951
|
const out = [];
|
|
@@ -3986,10 +3996,11 @@ var XML_ENTITIES = {
|
|
|
3986
3996
|
"'": "'"
|
|
3987
3997
|
};
|
|
3988
3998
|
function ssmlToText(ssml) {
|
|
3989
|
-
return ssml.replace(/<[^>]+>/g, "").replace(
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3999
|
+
return ssml.replace(/<[^>]+>/g, "").replace(/&(?:amp|lt|gt|quot|apos);|&#(\d+);/g, (entity, decimal) => {
|
|
4000
|
+
if (decimal === void 0) return XML_ENTITIES[entity] ?? entity;
|
|
4001
|
+
const n = Number(decimal);
|
|
4002
|
+
return n <= 1114111 ? String.fromCodePoint(n) : entity;
|
|
4003
|
+
}).trim();
|
|
3993
4004
|
}
|
|
3994
4005
|
function bannerLanes(banner) {
|
|
3995
4006
|
const components = banner.sub?.components ?? [];
|
|
@@ -4045,7 +4056,7 @@ var GuidanceBanner = class {
|
|
|
4045
4056
|
this.design = design;
|
|
4046
4057
|
this.element = doc.createElement("div");
|
|
4047
4058
|
this.element.className = "mapmap-banner";
|
|
4048
|
-
this.element.style.cssText = design ? `display:none;align-items:center;box-sizing:border-box;gap:${Math.round((design.padding ?? 10) * 1.2)}px;padding:${design.padding ?? 10}px ${Math.round((design.padding ?? 10) * 1.4)}px;background:${design.background};color:${design.textColor};border-radius:${design.cornerRadius ?? 10}px;max-width:${design.maxWidth ?? 340}px;` + (design.height !== void 0 ? `min-height:${design.height}px;` : "") + `font:600 ${design.fontSize}px/1.3 system-ui,sans-serif` : "display:none;gap:12px;align-items:center;padding:10px 14px;background:#101418;color:#fff;border-radius:10px;font:600 16px/1.3 system-ui,sans-serif";
|
|
4059
|
+
this.element.style.cssText = design ? `display:none;align-items:center;box-sizing:border-box;gap:${Math.round((design.padding ?? 10) * 1.2)}px;padding:${design.padding ?? 10}px ${Math.round((design.padding ?? 10) * 1.4)}px;background:${safeColour(design.background, "#101418")};color:${safeColour(design.textColor, "#ffffff")};border-radius:${design.cornerRadius ?? 10}px;max-width:${design.maxWidth ?? 340}px;` + (design.height !== void 0 ? `min-height:${design.height}px;` : "") + `font:600 ${design.fontSize}px/1.3 system-ui,sans-serif` : "display:none;gap:12px;align-items:center;padding:10px 14px;background:#101418;color:#fff;border-radius:10px;font:600 16px/1.3 system-ui,sans-serif";
|
|
4049
4060
|
container?.appendChild(this.element);
|
|
4050
4061
|
}
|
|
4051
4062
|
/**
|
|
@@ -4304,9 +4315,9 @@ var CameraAlertChip = class {
|
|
|
4304
4315
|
this.element.style.cssText = `display:${shown};gap:8px;align-items:center;padding:8px 12px;background:${this.escalated ? "#c0392b" : "#101418"};color:#fff;border-radius:10px;font:600 15px/1.3 system-ui,sans-serif`;
|
|
4305
4316
|
return;
|
|
4306
4317
|
}
|
|
4307
|
-
const background = this.escalated ? design.escalatedBackground : design.background;
|
|
4308
|
-
const color = this.escalated ? design.escalatedTextColor : design.textColor;
|
|
4309
|
-
this.element.style.cssText = `display:${shown};gap:8px;align-items:center;box-sizing:border-box;padding:8px 12px;background:${background};color:${color};border-radius:${design.cornerRadius}px;` + (design.outlineWidth > 0 ? `border:${design.outlineWidth}px solid ${design.outlineColor};` : "") + (CHIP_SLOT_CSS[design.chipPosition] ?? "") + "font:600 15px/1.3 system-ui,sans-serif";
|
|
4318
|
+
const background = this.escalated ? safeColour(design.escalatedBackground, "#c0392b") : safeColour(design.background, "#101418");
|
|
4319
|
+
const color = this.escalated ? safeColour(design.escalatedTextColor, "#ffffff") : safeColour(design.textColor, "#ffffff");
|
|
4320
|
+
this.element.style.cssText = `display:${shown};gap:8px;align-items:center;box-sizing:border-box;padding:8px 12px;background:${background};color:${color};border-radius:${design.cornerRadius}px;` + (design.outlineWidth > 0 ? `border:${design.outlineWidth}px solid ${safeColour(design.outlineColor, "#ffffff")};` : "") + (CHIP_SLOT_CSS[design.chipPosition] ?? "") + "font:600 15px/1.3 system-ui,sans-serif";
|
|
4310
4321
|
}
|
|
4311
4322
|
};
|
|
4312
4323
|
|