@tileflow/interactions 0.1.0-alpha.4 → 0.1.0-alpha.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/maplibre-entry.js +17 -11
- package/package.json +1 -1
package/dist/maplibre-entry.js
CHANGED
|
@@ -1662,7 +1662,7 @@ var tileflowInteractionActionSchema = z.discriminatedUnion("type", [
|
|
|
1662
1662
|
|
|
1663
1663
|
// src/maplibre-poi.ts
|
|
1664
1664
|
var interactionManifestMetadataKey = "tileflow:interaction-manifest";
|
|
1665
|
-
var interactionManifestVersion =
|
|
1665
|
+
var interactionManifestVersion = 3;
|
|
1666
1666
|
var missingSourceLayerNamespace = "tileflow-no-source-layer";
|
|
1667
1667
|
function createTileflowMapLibrePoiController(options) {
|
|
1668
1668
|
let bindings = semanticPoiBindings(options.bindings ?? [], options.onDiagnostic);
|
|
@@ -1726,9 +1726,20 @@ function createTileflowMapLibrePoiController(options) {
|
|
|
1726
1726
|
);
|
|
1727
1727
|
continue;
|
|
1728
1728
|
}
|
|
1729
|
+
const properties = normalizePoiProperties(feature.properties, manifest.fields);
|
|
1730
|
+
const category = properties.category;
|
|
1731
|
+
if (category === void 0) {
|
|
1732
|
+
manifestMismatch = true;
|
|
1733
|
+
diagnostic(
|
|
1734
|
+
options.onDiagnostic,
|
|
1735
|
+
"SEMANTIC_MANIFEST_MISMATCH",
|
|
1736
|
+
"A rendered POI feature has no supported category."
|
|
1737
|
+
);
|
|
1738
|
+
continue;
|
|
1739
|
+
}
|
|
1729
1740
|
const binding = bindings.find((candidate) => {
|
|
1730
1741
|
const target = candidate.target;
|
|
1731
|
-
return target.kind === "semantic-feature" && target.domain === "poi" && (!target.categories || target.categories.includes(
|
|
1742
|
+
return target.kind === "semantic-feature" && target.domain === "poi" && (!target.categories || target.categories.includes(category));
|
|
1732
1743
|
});
|
|
1733
1744
|
if (!binding) continue;
|
|
1734
1745
|
const featureId = normalizeFeatureId(feature.id);
|
|
@@ -1742,9 +1753,9 @@ function createTileflowMapLibrePoiController(options) {
|
|
|
1742
1753
|
coordinate: [event.lngLat.lng, event.lngLat.lat],
|
|
1743
1754
|
domain: "poi",
|
|
1744
1755
|
feature: {
|
|
1745
|
-
category
|
|
1756
|
+
category,
|
|
1746
1757
|
...featureId === void 0 ? {} : { id: featureId },
|
|
1747
|
-
properties
|
|
1758
|
+
properties
|
|
1748
1759
|
},
|
|
1749
1760
|
kind: "semantic-feature"
|
|
1750
1761
|
}
|
|
@@ -1974,7 +1985,7 @@ function parsePoiManifest(styleInput, onDiagnostic) {
|
|
|
1974
1985
|
for (const input of layerInputs) {
|
|
1975
1986
|
const layer = asRecord(input);
|
|
1976
1987
|
const sourceLayer = layer?.sourceLayer;
|
|
1977
|
-
if (!layer || !
|
|
1988
|
+
if (!layer || !isSafeManifestName(layer.layerId) || !isSafeManifestName(layer.source) || sourceLayer !== void 0 && !isSafeManifestName(sourceLayer) || layer.anchor !== "pointer-coordinate" || !isPoiRepresentation(layer.representation) || !Number.isSafeInteger(layer.priority) || layer.priority < 0 || layer.priority > 1e5 || ids.has(layer.layerId)) {
|
|
1978
1989
|
diagnostic(onDiagnostic, "SEMANTIC_MANIFEST_MISMATCH", "Invalid semantic POI layer lookup.");
|
|
1979
1990
|
return null;
|
|
1980
1991
|
}
|
|
@@ -2002,7 +2013,6 @@ function parsePoiManifest(styleInput, onDiagnostic) {
|
|
|
2002
2013
|
identityNamespace = namespace;
|
|
2003
2014
|
ids.add(layer.layerId);
|
|
2004
2015
|
layers.push({
|
|
2005
|
-
category: layer.category,
|
|
2006
2016
|
layerId: layer.layerId,
|
|
2007
2017
|
priority: layer.priority,
|
|
2008
2018
|
representation: layer.representation,
|
|
@@ -2072,11 +2082,7 @@ function sourceLayerNamespace(sourceLayer) {
|
|
|
2072
2082
|
return sourceLayer ?? missingSourceLayerNamespace;
|
|
2073
2083
|
}
|
|
2074
2084
|
function relevantLayerIds(manifest, bindings) {
|
|
2075
|
-
return manifest.layers.
|
|
2076
|
-
(layer) => bindings.some(
|
|
2077
|
-
(binding) => binding.target.kind === "semantic-feature" && (!binding.target.categories || binding.target.categories.includes(layer.category))
|
|
2078
|
-
)
|
|
2079
|
-
).map((layer) => layer.layerId);
|
|
2085
|
+
return bindings.some((binding) => binding.target.kind === "semantic-feature") ? manifest.layers.map((layer) => layer.layerId) : [];
|
|
2080
2086
|
}
|
|
2081
2087
|
function normalizePoiProperties(properties, fields) {
|
|
2082
2088
|
const source = properties ?? {};
|