diff --git a/package.json b/package.json index e4d329ec..7f80c88b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "worldwideview", - "version": "1.9.1", + "version": "1.10.0", "private": true, "scripts": { "setup": "node scripts/setup.mjs", diff --git a/packages/wwv-plugin-conflict-zones/package.json b/packages/wwv-plugin-conflict-zones/package.json index c74fff81..19a0122c 100644 --- a/packages/wwv-plugin-conflict-zones/package.json +++ b/packages/wwv-plugin-conflict-zones/package.json @@ -1,6 +1,6 @@ { "name": "@worldwideview/wwv-plugin-conflict-zones", - "version": "1.0.0", + "version": "1.1.0", "description": "WorldWideView plugin — Active conflict zones and geopolitical hotspots worldwide.", "main": "src/index.tsx", "types": "src/index.tsx", diff --git a/packages/wwv-plugin-conflict-zones/src/index.tsx b/packages/wwv-plugin-conflict-zones/src/index.tsx index 01e75cc3..6830f06e 100644 --- a/packages/wwv-plugin-conflict-zones/src/index.tsx +++ b/packages/wwv-plugin-conflict-zones/src/index.tsx @@ -17,6 +17,36 @@ function severityToColor(score: number): string { return "#fbbf24"; // Monitoring — yellow } +/** Attach _wwvEntity to a Resium Entity ref so InteractionHandler can pick it. */ +function bindWwvEntity(ref: any, geoEntity: GeoEntity): void { + const cesiumEntity = ref?.cesiumElement; + if (cesiumEntity && !cesiumEntity._wwvEntity) { + cesiumEntity._wwvEntity = geoEntity; + } +} + +/** Build a synthetic GeoEntity from a static ConflictZone definition. */ +function zoneToGeoEntity(zone: typeof CONFLICT_ZONES[number]): GeoEntity { + return { + id: zone.id, + pluginId: "conflict-zones", + latitude: zone.lat, + longitude: zone.lon, + altitude: 0, + timestamp: new Date(), + properties: { + name: zone.name, + description: zone.description, + type: zone.subtext || "N/A", + status: zone.status, + escalationScore: zone.escalationScore, + escalationTrend: zone.escalationTrend, + whyItMatters: zone.whyItMatters, + radiusKm: zone.radiusKm, + }, + }; +} + const ConflictZonesRenderer: React.FC<{ viewer: Cesium.Viewer | null; enabled: boolean }> = ({ enabled }) => { if (!enabled) return null; @@ -28,24 +58,14 @@ const ConflictZonesRenderer: React.FC<{ viewer: Cesium.Viewer | null; enabled: b const fillColor = Cesium.Color.fromCssColorString(colorHex).withAlpha(0.25); const outlineColor = Cesium.Color.fromCssColorString(colorHex).withAlpha(0.8); const radiusMeters = zone.radiusKm * 1000; + const geoEntity = zoneToGeoEntity(zone); return ( - - Overview${zone.description} - Type${zone.subtext || "N/A"} - Status${zone.status} - Escalation Score${zone.escalationScore} / 5 - Trend${zone.escalationTrend} - Why It Matters${zone.whyItMatters} - - - `} + ref={(ref: any) => bindWwvEntity(ref, geoEntity)} > = { "high": "#ef4444", // Red }; +/** Attach _wwvEntity to a Resium Entity ref so InteractionHandler can pick it. */ +function bindWwvEntity(ref: any, geoEntity: GeoEntity): void { + const cesiumEntity = ref?.cesiumElement; + if (cesiumEntity && !cesiumEntity._wwvEntity) { + cesiumEntity._wwvEntity = geoEntity; + } +} + export class InternationalSanctionsPlugin implements WorldPlugin { id = "international-sanctions"; name = "International Sanctions"; @@ -164,10 +172,13 @@ export class InternationalSanctionsPlugin implements WorldPlugin { const elements = useMemo(() => { if (!enabled || Object.keys(countryPolygons).length === 0 || this.data.length === 0) return []; - const results = []; + const results: Array<{ + id: string; name: string; geoEntity: GeoEntity; + color: Color; outlineColor: Color; height: number; + hierarchies: PolygonHierarchy[]; + }> = []; for (const entity of this.data) { const code = entity.properties.countryCode as string; - const count = entity.properties.count as number; const level = (entity.properties.level as string) || "low"; const hexStr = LEVEL_COLORS[level] || LEVEL_COLORS["low"]; const color = Color.fromCssColorString(hexStr).withAlpha(0.65); @@ -180,13 +191,7 @@ export class InternationalSanctionsPlugin implements WorldPlugin { results.push({ id: entity.id, name: `Sanctioned Country: ${code}`, - description: ` -
-
Target Area: ${code}
-
Level: ${level.toUpperCase()}
-
Active OFAC Sanctions: ${count}
-
- `, + geoEntity: entity, color, outlineColor, height, @@ -205,7 +210,7 @@ export class InternationalSanctionsPlugin implements WorldPlugin { bindWwvEntity(ref, rc.geoEntity)} > = { + low: "#facc15", medium: "#f97316", high: "#ef4444", +}; + +const SEVERITY_LABELS: Record = { + 5: "Critical", 4: "High", 3: "Elevated", 2: "Watchlist", +}; + export function EntityInfoCard() { const hoveredEntity = useStore((s) => s.hoveredEntity); const screenPos = useStore((s) => s.hoveredScreenPosition); @@ -67,6 +75,18 @@ export function EntityInfoCard() { const casualtiesDisplay = hoveredEntity.properties?.casualties !== undefined ? String(hoveredEntity.properties.casualties) : null; + // Sanctions-specific fields + const sanctionLevel = hoveredEntity.properties?.level as string | undefined; + const sanctionCount = hoveredEntity.properties?.count as number | undefined; + const countryCode = hoveredEntity.properties?.countryCode as string | undefined; + const isSanctions = hoveredEntity.pluginId === "international-sanctions"; + + // Conflict zone-specific fields + const escalationScore = hoveredEntity.properties?.escalationScore as number | undefined; + const zoneStatus = hoveredEntity.properties?.status as string | undefined; + const escalationTrend = hoveredEntity.properties?.escalationTrend as string | undefined; + const isConflictZone = hoveredEntity.pluginId === "conflict-zones"; + return (
)} + + {/* Sanctions-specific hover intel */} + {isSanctions && countryCode && ( +
+ Country + {countryCode} +
+ )} + {isSanctions && sanctionLevel && ( +
+ Severity + + {sanctionLevel.toUpperCase()} + +
+ )} + {isSanctions && sanctionCount !== undefined && ( +
+ OFAC Sanctions + {sanctionCount} +
+ )} + + {/* Conflict zone-specific hover intel */} + {isConflictZone && escalationScore !== undefined && ( +
+ Escalation + = 5 ? "#991b1b" : escalationScore >= 4 ? "#ef4444" : escalationScore >= 3 ? "#f97316" : "#fbbf24" }}> + {SEVERITY_LABELS[escalationScore] || escalationScore} / 5 + +
+ )} + {isConflictZone && zoneStatus && ( +
+ Status + {zoneStatus} +
+ )} + {isConflictZone && escalationTrend && ( +
+ Trend + {escalationTrend} +
+ )} {/* Footer hint */} @@ -156,3 +220,4 @@ export function EntityInfoCard() { ); } +