ochre-sdk 1.0.4 → 1.0.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/dist/index.mjs +14 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5941,10 +5941,23 @@ function parseResponsiveCssStyles(properties) {
|
|
|
5941
5941
|
* @returns Parsed bounds object
|
|
5942
5942
|
*/
|
|
5943
5943
|
function parseBounds(bounds) {
|
|
5944
|
-
const [southWest, northEast] = bounds.split(";").map((pair) => pair.split(",").map((coordinate) => Number.parseFloat(coordinate.trim())));
|
|
5944
|
+
const [southWest, northEast] = bounds.trim().startsWith("[") ? parseJsonBounds(bounds) : bounds.split(";").map((pair) => pair.split(",").map((coordinate) => Number.parseFloat(coordinate.trim())));
|
|
5945
5945
|
if (southWest?.length !== 2 || northEast?.length !== 2 || southWest.some((coordinate) => Number.isNaN(coordinate)) || northEast.some((coordinate) => Number.isNaN(coordinate))) throw new Error(`Invalid bounds: ${bounds}`);
|
|
5946
5946
|
return [[southWest[0], southWest[1]], [northEast[0], northEast[1]]];
|
|
5947
5947
|
}
|
|
5948
|
+
function parseJsonBounds(bounds) {
|
|
5949
|
+
let parsed;
|
|
5950
|
+
try {
|
|
5951
|
+
parsed = JSON.parse(bounds);
|
|
5952
|
+
} catch {
|
|
5953
|
+
throw new Error(`Invalid bounds: ${bounds}`);
|
|
5954
|
+
}
|
|
5955
|
+
if (!isNumberPairArray(parsed)) throw new Error(`Invalid bounds: ${bounds}`);
|
|
5956
|
+
return parsed;
|
|
5957
|
+
}
|
|
5958
|
+
function isNumberPairArray(value) {
|
|
5959
|
+
return Array.isArray(value) && value.every((pair) => Array.isArray(pair) && pair.every((coordinate) => typeof coordinate === "number"));
|
|
5960
|
+
}
|
|
5948
5961
|
/**
|
|
5949
5962
|
* Parses all context option arrays from an options object.
|
|
5950
5963
|
*
|