Skip to content

armgit / mapcn

Public Imported from GitHub
0

Beautiful map components. 100% Free, Zero config, one command setup.

TypeScript

Updates registry build to fix import

Anmoldeep Singha68373eee84e
diff --git a/package.json b/package.json
index 2f49190..8d8f207 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
"build": "next build",
"start": "next start",
"lint": "eslint",
- "registry:build": "npx shadcn build -o ./public/r"
+ "registry:build": "npx shadcn build -o ./public/r && npx tsx scripts/fix-registry-imports.ts"
},
"dependencies": {
"@vercel/analytics": "^1.6.1",
diff --git a/public/r/analytics-map.json b/public/r/analytics-map.json
index 82681d3..2c1b482 100644
--- a/public/r/analytics-map.json
+++ b/public/r/analytics-map.json
@@ -15,7 +15,7 @@
"files": [
{
"path": "src/registry/blocks/analytics-map/page.tsx",
- "content": "\"use client\";\n\nimport {\n Map,\n MapControls,\n MapMarker,\n MarkerContent,\n MarkerTooltip,\n} from \"@/registry/map\";\nimport { OverviewCard } from \"./components/overview-card\";\nimport { BreakdownCard } from \"./components/breakdown-card\";\nimport {\n locations,\n visitedPagesRows,\n countriesRows,\n referrersRows,\n browsersRows,\n} from \"./data\";\n\nconst MAP_HEIGHT = \"38rem\";\n\nexport function AnalyticsMapBlock() {\n return (\n <div\n className=\"bg-background relative min-h-screen\"\n style={{ \"--map-height\": MAP_HEIGHT } as React.CSSProperties}\n >\n <div className=\"relative h-(--map-height)\">\n <Map\n center={[-2, 16]}\n zoom={1.5}\n scrollZoom={false}\n renderWorldCopies={true}\n >\n <MapControls showFullscreen />\n {locations.map((location) => (\n <MapMarker\n key={location.city}\n longitude={location.lng}\n latitude={location.lat}\n >\n <MarkerContent>\n <div\n className=\"rounded-full bg-blue-500/70\"\n style={{\n width: location.size * 3,\n height: location.size * 3,\n }}\n />\n </MarkerContent>\n <MarkerTooltip\n offset={20}\n className=\"bg-background text-foreground border\"\n >\n <p className=\"text-muted-foreground font-medium\">\n {location.city}\n </p>\n <p className=\"mt-1\">\n <span className=\"font-medium tabular-nums\">\n {location.size}\n </span>{\" \"}\n active users\n </p>\n </MarkerTooltip>\n </MapMarker>\n ))}\n </Map>\n <div\n className=\"via-background/30 to-background pointer-events-none absolute inset-x-0 bottom-0 h-40 bg-linear-to-b from-transparent\"\n aria-hidden\n />\n <OverviewCard />\n </div>\n\n <div className=\"grid gap-4 p-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4\">\n <BreakdownCard title=\"Visited pages\" rows={visitedPagesRows} />\n <BreakdownCard title=\"Referrers\" rows={referrersRows} />\n <BreakdownCard title=\"Countries\" rows={countriesRows} />\n <BreakdownCard title=\"Browsers\" rows={browsersRows} />\n </div>\n </div>\n );\n}\n",
+ "content": "\"use client\";\n\nimport {\n Map,\n MapControls,\n MapMarker,\n MarkerContent,\n MarkerTooltip,\n} from \"@/components/ui/map\";\nimport { OverviewCard } from \"./components/overview-card\";\nimport { BreakdownCard } from \"./components/breakdown-card\";\nimport {\n locations,\n visitedPagesRows,\n countriesRows,\n referrersRows,\n browsersRows,\n} from \"./data\";\n\nconst MAP_HEIGHT = \"38rem\";\n\nexport function AnalyticsMapBlock() {\n return (\n <div\n className=\"bg-background relative min-h-screen\"\n style={{ \"--map-height\": MAP_HEIGHT } as React.CSSProperties}\n >\n <div className=\"relative h-(--map-height)\">\n <Map\n center={[-2, 16]}\n zoom={1.5}\n scrollZoom={false}\n renderWorldCopies={true}\n >\n <MapControls showFullscreen />\n {locations.map((location) => (\n <MapMarker\n key={location.city}\n longitude={location.lng}\n latitude={location.lat}\n >\n <MarkerContent>\n <div\n className=\"rounded-full bg-blue-500/70\"\n style={{\n width: location.size * 3,\n height: location.size * 3,\n }}\n />\n </MarkerContent>\n <MarkerTooltip\n offset={20}\n className=\"bg-background text-foreground border\"\n >\n <p className=\"text-muted-foreground font-medium\">\n {location.city}\n </p>\n <p className=\"mt-1\">\n <span className=\"font-medium tabular-nums\">\n {location.size}\n </span>{\" \"}\n active users\n </p>\n </MarkerTooltip>\n </MapMarker>\n ))}\n </Map>\n <div\n className=\"via-background/30 to-background pointer-events-none absolute inset-x-0 bottom-0 h-40 bg-linear-to-b from-transparent\"\n aria-hidden\n />\n <OverviewCard />\n </div>\n\n <div className=\"grid gap-4 p-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4\">\n <BreakdownCard title=\"Visited pages\" rows={visitedPagesRows} />\n <BreakdownCard title=\"Referrers\" rows={referrersRows} />\n <BreakdownCard title=\"Countries\" rows={countriesRows} />\n <BreakdownCard title=\"Browsers\" rows={browsersRows} />\n </div>\n </div>\n );\n}\n",
"type": "registry:page",
"target": "app/analytics/page.tsx"
},
@@ -46,4 +46,4 @@
"dashboard"
],
"type": "registry:block"
-}
\ No newline at end of file
+}
diff --git a/public/r/delivery-tracker.json b/public/r/delivery-tracker.json
index bde6de3..e9c5bd7 100644
--- a/public/r/delivery-tracker.json
+++ b/public/r/delivery-tracker.json
@@ -15,7 +15,7 @@
"files": [
{
"path": "src/registry/blocks/delivery-tracker/page.tsx",
- "content": "\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { Clock3, Utensils, Truck, UserRound } from \"lucide-react\";\n\nimport {\n Map,\n MapMarker,\n MapRoute,\n MarkerContent,\n MarkerTooltip,\n} from \"@/registry/map\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface DeliveryMeal {\n name: string;\n price: string;\n quantity: number;\n}\n\ninterface OsrmRouteData {\n coordinates: [number, number][];\n duration: number;\n distance: number;\n}\n\nconst deliveryMeals: DeliveryMeal[] = [\n {\n name: \"Spicy Tofu Grain Bowl\",\n price: \"$44.00\",\n quantity: 1,\n },\n {\n name: \"Herb Chicken Rice Box\",\n price: \"$58.00\",\n quantity: 2,\n },\n {\n name: \"Roasted Veggie Wrap\",\n price: \"$29.00\",\n quantity: 1,\n },\n];\n\nconst pickup = { lng: -122.466, lat: 37.716 };\nconst dropoff = { lng: -122.399, lat: 37.683 };\n\nfunction formatDistance(meters?: number) {\n if (!meters) return \"--\";\n if (meters < 1000) return `${Math.round(meters)} m`;\n return `${(meters / 1000).toFixed(1)} km`;\n}\n\nfunction formatDuration(seconds?: number) {\n if (!seconds) return \"--\";\n const minutes = Math.round(seconds / 60);\n if (minutes < 60) return `${minutes} min`;\n const hours = Math.floor(minutes / 60);\n const remainingMinutes = minutes % 60;\n return `${hours}h ${remainingMinutes}m`;\n}\n\nexport function DeliveryBlock() {\n const [routeData, setRouteData] = useState<OsrmRouteData | null>(null);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n async function fetchRoute() {\n setLoading(true);\n try {\n const response = await fetch(\n `https://router.project-osrm.org/route/v1/driving/${pickup.lng},${pickup.lat};${dropoff.lng},${dropoff.lat}?overview=full&geometries=geojson`\n );\n const data = await response.json();\n const route = data?.routes?.[0];\n if (!route?.geometry?.coordinates) return;\n\n setRouteData({\n coordinates: route.geometry.coordinates as [number, number][],\n duration: route.duration as number,\n distance: route.distance as number,\n });\n } catch (error) {\n console.error(\"Failed to fetch route:\", error);\n } finally {\n setLoading(false);\n }\n }\n\n fetchRoute();\n }, []);\n\n const progressCoordinates = useMemo(() => {\n const progressCount = Math.max(\n 2,\n Math.floor(\n (routeData?.coordinates?.length ?? 0) * (routeData ? 0.62 : 0.66)\n )\n );\n return routeData?.coordinates?.slice(0, progressCount) ?? [];\n }, [routeData]);\n\n const courierPosition = progressCoordinates[progressCoordinates.length - 1];\n\n return (\n <div className=\"p-8\">\n <div className=\"grid md:grid-cols-[1.05fr_1fr] bg-sidebar rounded-lg border md:h-[600px] max-w-7xl mx-auto\">\n <div className=\"p-5 md:p-6 flex flex-col\">\n <div className=\"space-y-1\">\n <h3 className=\"text-2xl font-semibold tracking-tight\">\n Track Delivery\n </h3>\n <p className=\"text-sm text-muted-foreground\">Mon Feb 10 - 2-3 PM</p>\n </div>\n\n <Card className=\"mt-5\">\n <CardHeader>\n <CardTitle className=\"font-medium\">\n Order items ({deliveryMeals.length})\n </CardTitle>\n </CardHeader>\n <CardContent className=\"space-y-5\">\n {deliveryMeals.map((meal) => (\n <div key={meal.name} className=\"flex items-center gap-3\">\n <div className=\"grid size-8 place-items-center rounded-full bg-muted text-xs font-medium\">\n <Utensils className=\"size-4 text-muted-foreground\" />\n </div>\n <div className=\"min-w-4 flex-1\">\n <p className=\"truncate text-sm font-medium pb-1\">\n {meal.name}\n </p>\n <p className=\"text-xs text-muted-foreground\">\n {meal.price}\n </p>\n </div>\n <Badge\n variant=\"secondary\"\n className=\"h-6 rounded-full px-2.5\"\n >\n x{meal.quantity}\n </Badge>\n </div>\n ))}\n <div className=\"flex items-center justify-between border-t border-border/60 pt-3 text-sm\">\n <span className=\"text-muted-foreground\">Bundle total</span>\n <span className=\"font-medium\">$189.00</span>\n </div>\n </CardContent>\n </Card>\n\n <div className=\"mt-4 grid gap-3 sm:grid-cols-2\">\n <Card>\n <CardContent className=\"space-y-2\">\n <p className=\"text-sm font-medium text-muted-foreground\">\n Pickup confirmed\n </p>\n <p className=\"text-sm font-medium\">Mon, Feb 10 at 1:48 PM</p>\n </CardContent>\n </Card>\n <Card>\n <CardContent className=\"space-y-2\">\n <p className=\"text-sm font-medium text-muted-foreground\">\n Remaining travel\n </p>\n <p className=\"text-sm font-medium\">\n {formatDuration(routeData?.duration)}\n </p>\n </CardContent>\n </Card>\n </div>\n\n <div className=\"mt-6 flex flex-wrap items-center gap-2\">\n <Button size=\"sm\" className=\"gap-1.5\">\n <Clock3 className=\"size-4\" />\n View timeline\n </Button>\n <Button variant=\"outline\" size=\"sm\" className=\"gap-1.5\">\n <UserRound className=\"size-4\" />\n Contact courier\n </Button>\n </div>\n </div>\n\n <div className=\"relative h-[400px] overflow-hidden rounded-xl md:h-full shadow-sm\">\n <Map\n loading={loading}\n center={[-122.435, 37.696]}\n zoom={12}\n minZoom={10}\n maxZoom={16}\n styles={{\n light: \"https://tiles.openfreemap.org/styles/bright\",\n dark: \"https://tiles.openfreemap.org/styles/dark\",\n }}\n >\n <MapRoute\n id=\"delivery-full-route\"\n coordinates={routeData?.coordinates ?? []}\n color=\"#5b6572\"\n width={5.2}\n opacity={0.3}\n interactive={false}\n />\n <MapRoute\n id=\"delivery-progress-route\"\n coordinates={progressCoordinates}\n color=\"#3b82f6\"\n width={6}\n opacity={0.95}\n interactive={false}\n />\n\n {courierPosition && (\n <MapMarker\n longitude={courierPosition[0]}\n latitude={courierPosition[1]}\n offset={[0, 10]}\n >\n <MarkerContent>\n <div className=\"relative grid size-9 place-items-center rounded-full bg-emerald-500 dark:bg-emerald-600\">\n <Truck className=\"size-4 text-white\" />\n </div>\n </MarkerContent>\n <MarkerTooltip>\n <div className=\"space-y-0.5 text-xs\">\n <p className=\"font-medium\">\n Order {formatDuration(routeData?.duration)} away\n </p>\n <p className=\"text-muted-foreground\">\n Route {formatDistance(routeData?.distance)}\n </p>\n </div>\n </MarkerTooltip>\n </MapMarker>\n )}\n\n <MapMarker longitude={pickup.lng} latitude={pickup.lat}>\n <MarkerContent>\n <div className=\"size-4 rounded-full border-2 border-white bg-emerald-500 shadow-sm\" />\n </MarkerContent>\n <MarkerTooltip>\n <p className=\"text-xs font-medium\">Origin</p>\n </MarkerTooltip>\n </MapMarker>\n\n <MapMarker longitude={dropoff.lng} latitude={dropoff.lat}>\n <MarkerContent>\n <div className=\"size-4 rounded-full border-2 border-white bg-rose-500 shadow-sm\" />\n </MarkerContent>\n <MarkerTooltip>\n <p className=\"text-xs font-medium\">Destination</p>\n </MarkerTooltip>\n </MapMarker>\n </Map>\n </div>\n </div>\n </div>\n );\n}\n",
+ "content": "\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { Clock3, Utensils, Truck, UserRound } from \"lucide-react\";\n\nimport {\n Map,\n MapMarker,\n MapRoute,\n MarkerContent,\n MarkerTooltip,\n} from \"@/components/ui/map\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface DeliveryMeal {\n name: string;\n price: string;\n quantity: number;\n}\n\ninterface OsrmRouteData {\n coordinates: [number, number][];\n duration: number;\n distance: number;\n}\n\nconst deliveryMeals: DeliveryMeal[] = [\n {\n name: \"Spicy Tofu Grain Bowl\",\n price: \"$44.00\",\n quantity: 1,\n },\n {\n name: \"Herb Chicken Rice Box\",\n price: \"$58.00\",\n quantity: 2,\n },\n {\n name: \"Roasted Veggie Wrap\",\n price: \"$29.00\",\n quantity: 1,\n },\n];\n\nconst pickup = { lng: -122.466, lat: 37.716 };\nconst dropoff = { lng: -122.399, lat: 37.683 };\n\nfunction formatDistance(meters?: number) {\n if (!meters) return \"--\";\n if (meters < 1000) return `${Math.round(meters)} m`;\n return `${(meters / 1000).toFixed(1)} km`;\n}\n\nfunction formatDuration(seconds?: number) {\n if (!seconds) return \"--\";\n const minutes = Math.round(seconds / 60);\n if (minutes < 60) return `${minutes} min`;\n const hours = Math.floor(minutes / 60);\n const remainingMinutes = minutes % 60;\n return `${hours}h ${remainingMinutes}m`;\n}\n\nexport function DeliveryBlock() {\n const [routeData, setRouteData] = useState<OsrmRouteData | null>(null);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n async function fetchRoute() {\n setLoading(true);\n try {\n const response = await fetch(\n `https://router.project-osrm.org/route/v1/driving/${pickup.lng},${pickup.lat};${dropoff.lng},${dropoff.lat}?overview=full&geometries=geojson`\n );\n const data = await response.json();\n const route = data?.routes?.[0];\n if (!route?.geometry?.coordinates) return;\n\n setRouteData({\n coordinates: route.geometry.coordinates as [number, number][],\n duration: route.duration as number,\n distance: route.distance as number,\n });\n } catch (error) {\n console.error(\"Failed to fetch route:\", error);\n } finally {\n setLoading(false);\n }\n }\n\n fetchRoute();\n }, []);\n\n const progressCoordinates = useMemo(() => {\n const progressCount = Math.max(\n 2,\n Math.floor(\n (routeData?.coordinates?.length ?? 0) * (routeData ? 0.62 : 0.66)\n )\n );\n return routeData?.coordinates?.slice(0, progressCount) ?? [];\n }, [routeData]);\n\n const courierPosition = progressCoordinates[progressCoordinates.length - 1];\n\n return (\n <div className=\"p-8\">\n <div className=\"grid md:grid-cols-[1.05fr_1fr] bg-sidebar rounded-lg border md:h-[600px] max-w-7xl mx-auto\">\n <div className=\"p-5 md:p-6 flex flex-col\">\n <div className=\"space-y-1\">\n <h3 className=\"text-2xl font-semibold tracking-tight\">\n Track Delivery\n </h3>\n <p className=\"text-sm text-muted-foreground\">Mon Feb 10 - 2-3 PM</p>\n </div>\n\n <Card className=\"mt-5\">\n <CardHeader>\n <CardTitle className=\"font-medium\">\n Order items ({deliveryMeals.length})\n </CardTitle>\n </CardHeader>\n <CardContent className=\"space-y-5\">\n {deliveryMeals.map((meal) => (\n <div key={meal.name} className=\"flex items-center gap-3\">\n <div className=\"grid size-8 place-items-center rounded-full bg-muted text-xs font-medium\">\n <Utensils className=\"size-4 text-muted-foreground\" />\n </div>\n <div className=\"min-w-4 flex-1\">\n <p className=\"truncate text-sm font-medium pb-1\">\n {meal.name}\n </p>\n <p className=\"text-xs text-muted-foreground\">\n {meal.price}\n </p>\n </div>\n <Badge\n variant=\"secondary\"\n className=\"h-6 rounded-full px-2.5\"\n >\n x{meal.quantity}\n </Badge>\n </div>\n ))}\n <div className=\"flex items-center justify-between border-t border-border/60 pt-3 text-sm\">\n <span className=\"text-muted-foreground\">Bundle total</span>\n <span className=\"font-medium\">$189.00</span>\n </div>\n </CardContent>\n </Card>\n\n <div className=\"mt-4 grid gap-3 sm:grid-cols-2\">\n <Card>\n <CardContent className=\"space-y-2\">\n <p className=\"text-sm font-medium text-muted-foreground\">\n Pickup confirmed\n </p>\n <p className=\"text-sm font-medium\">Mon, Feb 10 at 1:48 PM</p>\n </CardContent>\n </Card>\n <Card>\n <CardContent className=\"space-y-2\">\n <p className=\"text-sm font-medium text-muted-foreground\">\n Remaining travel\n </p>\n <p className=\"text-sm font-medium\">\n {formatDuration(routeData?.duration)}\n </p>\n </CardContent>\n </Card>\n </div>\n\n <div className=\"mt-6 flex flex-wrap items-center gap-2\">\n <Button size=\"sm\" className=\"gap-1.5\">\n <Clock3 className=\"size-4\" />\n View timeline\n </Button>\n <Button variant=\"outline\" size=\"sm\" className=\"gap-1.5\">\n <UserRound className=\"size-4\" />\n Contact courier\n </Button>\n </div>\n </div>\n\n <div className=\"relative h-[400px] overflow-hidden rounded-xl md:h-full shadow-sm\">\n <Map\n loading={loading}\n center={[-122.435, 37.696]}\n zoom={12}\n minZoom={10}\n maxZoom={16}\n styles={{\n light: \"https://tiles.openfreemap.org/styles/bright\",\n dark: \"https://tiles.openfreemap.org/styles/dark\",\n }}\n >\n <MapRoute\n id=\"delivery-full-route\"\n coordinates={routeData?.coordinates ?? []}\n color=\"#5b6572\"\n width={5.2}\n opacity={0.3}\n interactive={false}\n />\n <MapRoute\n id=\"delivery-progress-route\"\n coordinates={progressCoordinates}\n color=\"#3b82f6\"\n width={6}\n opacity={0.95}\n interactive={false}\n />\n\n {courierPosition && (\n <MapMarker\n longitude={courierPosition[0]}\n latitude={courierPosition[1]}\n offset={[0, 10]}\n >\n <MarkerContent>\n <div className=\"relative grid size-9 place-items-center rounded-full bg-emerald-500 dark:bg-emerald-600\">\n <Truck className=\"size-4 text-white\" />\n </div>\n </MarkerContent>\n <MarkerTooltip>\n <div className=\"space-y-0.5 text-xs\">\n <p className=\"font-medium\">\n Order {formatDuration(routeData?.duration)} away\n </p>\n <p className=\"text-muted-foreground\">\n Route {formatDistance(routeData?.distance)}\n </p>\n </div>\n </MarkerTooltip>\n </MapMarker>\n )}\n\n <MapMarker longitude={pickup.lng} latitude={pickup.lat}>\n <MarkerContent>\n <div className=\"size-4 rounded-full border-2 border-white bg-emerald-500 shadow-sm\" />\n </MarkerContent>\n <MarkerTooltip>\n <p className=\"text-xs font-medium\">Origin</p>\n </MarkerTooltip>\n </MapMarker>\n\n <MapMarker longitude={dropoff.lng} latitude={dropoff.lat}>\n <MarkerContent>\n <div className=\"size-4 rounded-full border-2 border-white bg-rose-500 shadow-sm\" />\n </MarkerContent>\n <MarkerTooltip>\n <p className=\"text-xs font-medium\">Destination</p>\n </MarkerTooltip>\n </MapMarker>\n </Map>\n </div>\n </div>\n </div>\n );\n}\n",
"type": "registry:page",
"target": "app/delivery/page.tsx"
}
@@ -28,4 +28,4 @@
"delivery"
],
"type": "registry:block"
-}
\ No newline at end of file
+}
diff --git a/public/r/heatmap.json b/public/r/heatmap.json
index 3855ebe..dcee674 100644
--- a/public/r/heatmap.json
+++ b/public/r/heatmap.json
@@ -11,7 +11,7 @@
"files": [
{
"path": "src/registry/blocks/heatmap/page.tsx",
- "content": "\"use client\";\n\nimport { useEffect, useId } from \"react\";\n\nimport { Map, useMap } from \"@/registry/map\";\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\";\n\nconst EARTHQUAKE_GEOJSON_URL =\n \"https://maplibre.org/maplibre-gl-js/docs/assets/earthquakes.geojson\";\n\nconst HEATMAP_GRADIENT_COLORS = [\n \"#fff7bc\",\n \"#fee391\",\n \"#fec44f\",\n \"#fe9929\",\n \"#d7301f\",\n];\n\nconst HEATMAP_COLOR_STOPS: [number, string][] = [\n [0.15, HEATMAP_GRADIENT_COLORS[0]],\n [0.35, HEATMAP_GRADIENT_COLORS[1]],\n [0.55, HEATMAP_GRADIENT_COLORS[2]],\n [0.75, HEATMAP_GRADIENT_COLORS[3]],\n [1, HEATMAP_GRADIENT_COLORS[4]],\n];\n\nfunction GlobeHeatmapLayers() {\n const { map, isLoaded } = useMap();\n const id = useId();\n const sourceId = `heatmap-source-${id}`;\n const heatLayerId = `heatmap-layer-${id}`;\n const pointLayerId = `heatmap-point-layer-${id}`;\n\n useEffect(() => {\n if (!map || !isLoaded) return;\n\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, {\n type: \"geojson\",\n data: EARTHQUAKE_GEOJSON_URL,\n });\n }\n\n if (!map.getLayer(heatLayerId)) {\n map.addLayer({\n id: heatLayerId,\n type: \"heatmap\",\n source: sourceId,\n maxzoom: 6,\n paint: {\n \"heatmap-weight\": [\n \"interpolate\",\n [\"linear\"],\n [\"get\", \"mag\"],\n 0,\n 0,\n 6,\n 0.8,\n ],\n \"heatmap-intensity\": [\n \"interpolate\",\n [\"linear\"],\n [\"zoom\"],\n 0,\n 0.55,\n 6,\n 1.25,\n ],\n \"heatmap-color\": [\n \"interpolate\",\n [\"linear\"],\n [\"heatmap-density\"],\n 0,\n \"rgba(59, 130, 246, 0)\",\n ...HEATMAP_COLOR_STOPS.flat(),\n ],\n \"heatmap-radius\": [\"interpolate\", [\"linear\"], [\"zoom\"], 0, 8, 6, 34],\n \"heatmap-opacity\": [\n \"interpolate\",\n [\"linear\"],\n [\"zoom\"],\n 4.5,\n 0.75,\n 6.5,\n 0.08,\n ],\n },\n });\n }\n\n if (!map.getLayer(pointLayerId)) {\n map.addLayer({\n id: pointLayerId,\n type: \"circle\",\n source: sourceId,\n minzoom: 4.5,\n paint: {\n \"circle-radius\": [\n \"interpolate\",\n [\"linear\"],\n [\"get\", \"mag\"],\n 1,\n 3,\n 6,\n 10,\n ],\n \"circle-color\": [\n \"interpolate\",\n [\"linear\"],\n [\"get\", \"mag\"],\n 1,\n HEATMAP_GRADIENT_COLORS[1],\n 2.5,\n HEATMAP_GRADIENT_COLORS[2],\n 4,\n HEATMAP_GRADIENT_COLORS[3],\n 6,\n HEATMAP_GRADIENT_COLORS[4],\n ],\n \"circle-stroke-width\": 1,\n \"circle-stroke-color\": \"rgba(255,255,255,0.8)\",\n \"circle-opacity\": [\n \"interpolate\",\n [\"linear\"],\n [\"zoom\"],\n 4.5,\n 0,\n 6.5,\n 0.7,\n ],\n },\n });\n }\n\n return () => {\n try {\n if (map.getLayer(pointLayerId)) map.removeLayer(pointLayerId);\n if (map.getLayer(heatLayerId)) map.removeLayer(heatLayerId);\n if (map.getSource(sourceId)) map.removeSource(sourceId);\n } catch {\n // ignore\n }\n };\n }, [map, isLoaded, sourceId, heatLayerId, pointLayerId]);\n\n return null;\n}\n\nexport function HeatmapBlock() {\n return (\n <div className=\"bg-muted/50 relative h-screen\">\n <div className=\"relative h-full\">\n <Map\n center={[-113, 43]}\n zoom={3.2}\n projection={{ type: \"globe\" }}\n pitch={24}\n minZoom={1.2}\n maxZoom={8}\n >\n <GlobeHeatmapLayers />\n </Map>\n </div>\n\n <Card className=\"absolute top-4 left-4 z-10 w-72\">\n <CardHeader>\n <CardTitle>Global Earthquakes Heatmap</CardTitle>\n </CardHeader>\n <CardContent>\n <div className=\"grid grid-cols-5 gap-1.5\">\n {HEATMAP_GRADIENT_COLORS.map((color) => (\n <span\n key={color}\n className=\"h-2.5 rounded-full\"\n style={{ backgroundColor: color }}\n />\n ))}\n </div>\n <div className=\"text-muted-foreground flex items-center justify-between pt-3 text-xs\">\n <span>Low</span>\n <span>High</span>\n </div>\n <p className=\"text-muted-foreground pt-2 text-xs\">\n Data source:{\" \"}\n <a\n href={EARTHQUAKE_GEOJSON_URL}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"hover:text-foreground underline underline-offset-4 transition-colors\"\n >\n MapLibre earthquakes.geojson\n </a>\n </p>\n </CardContent>\n </Card>\n </div>\n );\n}\n",
+ "content": "\"use client\";\n\nimport { useEffect, useId } from \"react\";\n\nimport { Map, useMap } from \"@/components/ui/map\";\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\";\n\nconst EARTHQUAKE_GEOJSON_URL =\n \"https://maplibre.org/maplibre-gl-js/docs/assets/earthquakes.geojson\";\n\nconst HEATMAP_GRADIENT_COLORS = [\n \"#fff7bc\",\n \"#fee391\",\n \"#fec44f\",\n \"#fe9929\",\n \"#d7301f\",\n];\n\nconst HEATMAP_COLOR_STOPS: [number, string][] = [\n [0.15, HEATMAP_GRADIENT_COLORS[0]],\n [0.35, HEATMAP_GRADIENT_COLORS[1]],\n [0.55, HEATMAP_GRADIENT_COLORS[2]],\n [0.75, HEATMAP_GRADIENT_COLORS[3]],\n [1, HEATMAP_GRADIENT_COLORS[4]],\n];\n\nfunction GlobeHeatmapLayers() {\n const { map, isLoaded } = useMap();\n const id = useId();\n const sourceId = `heatmap-source-${id}`;\n const heatLayerId = `heatmap-layer-${id}`;\n const pointLayerId = `heatmap-point-layer-${id}`;\n\n useEffect(() => {\n if (!map || !isLoaded) return;\n\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, {\n type: \"geojson\",\n data: EARTHQUAKE_GEOJSON_URL,\n });\n }\n\n if (!map.getLayer(heatLayerId)) {\n map.addLayer({\n id: heatLayerId,\n type: \"heatmap\",\n source: sourceId,\n maxzoom: 6,\n paint: {\n \"heatmap-weight\": [\n \"interpolate\",\n [\"linear\"],\n [\"get\", \"mag\"],\n 0,\n 0,\n 6,\n 0.8,\n ],\n \"heatmap-intensity\": [\n \"interpolate\",\n [\"linear\"],\n [\"zoom\"],\n 0,\n 0.55,\n 6,\n 1.25,\n ],\n \"heatmap-color\": [\n \"interpolate\",\n [\"linear\"],\n [\"heatmap-density\"],\n 0,\n \"rgba(59, 130, 246, 0)\",\n ...HEATMAP_COLOR_STOPS.flat(),\n ],\n \"heatmap-radius\": [\"interpolate\", [\"linear\"], [\"zoom\"], 0, 8, 6, 34],\n \"heatmap-opacity\": [\n \"interpolate\",\n [\"linear\"],\n [\"zoom\"],\n 4.5,\n 0.75,\n 6.5,\n 0.08,\n ],\n },\n });\n }\n\n if (!map.getLayer(pointLayerId)) {\n map.addLayer({\n id: pointLayerId,\n type: \"circle\",\n source: sourceId,\n minzoom: 4.5,\n paint: {\n \"circle-radius\": [\n \"interpolate\",\n [\"linear\"],\n [\"get\", \"mag\"],\n 1,\n 3,\n 6,\n 10,\n ],\n \"circle-color\": [\n \"interpolate\",\n [\"linear\"],\n [\"get\", \"mag\"],\n 1,\n HEATMAP_GRADIENT_COLORS[1],\n 2.5,\n HEATMAP_GRADIENT_COLORS[2],\n 4,\n HEATMAP_GRADIENT_COLORS[3],\n 6,\n HEATMAP_GRADIENT_COLORS[4],\n ],\n \"circle-stroke-width\": 1,\n \"circle-stroke-color\": \"rgba(255,255,255,0.8)\",\n \"circle-opacity\": [\n \"interpolate\",\n [\"linear\"],\n [\"zoom\"],\n 4.5,\n 0,\n 6.5,\n 0.7,\n ],\n },\n });\n }\n\n return () => {\n try {\n if (map.getLayer(pointLayerId)) map.removeLayer(pointLayerId);\n if (map.getLayer(heatLayerId)) map.removeLayer(heatLayerId);\n if (map.getSource(sourceId)) map.removeSource(sourceId);\n } catch {\n // ignore\n }\n };\n }, [map, isLoaded, sourceId, heatLayerId, pointLayerId]);\n\n return null;\n}\n\nexport function HeatmapBlock() {\n return (\n <div className=\"bg-muted/50 relative h-screen\">\n <div className=\"relative h-full\">\n <Map\n center={[-113, 43]}\n zoom={3.2}\n projection={{ type: \"globe\" }}\n pitch={24}\n minZoom={1.2}\n maxZoom={8}\n >\n <GlobeHeatmapLayers />\n </Map>\n </div>\n\n <Card className=\"absolute top-4 left-4 z-10 w-72\">\n <CardHeader>\n <CardTitle>Global Earthquakes Heatmap</CardTitle>\n </CardHeader>\n <CardContent>\n <div className=\"grid grid-cols-5 gap-1.5\">\n {HEATMAP_GRADIENT_COLORS.map((color) => (\n <span\n key={color}\n className=\"h-2.5 rounded-full\"\n style={{ backgroundColor: color }}\n />\n ))}\n </div>\n <div className=\"text-muted-foreground flex items-center justify-between pt-3 text-xs\">\n <span>Low</span>\n <span>High</span>\n </div>\n <p className=\"text-muted-foreground pt-2 text-xs\">\n Data source:{\" \"}\n <a\n href={EARTHQUAKE_GEOJSON_URL}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"hover:text-foreground underline underline-offset-4 transition-colors\"\n >\n MapLibre earthquakes.geojson\n </a>\n </p>\n </CardContent>\n </Card>\n </div>\n );\n}\n",
"type": "registry:page",
"target": "app/heatmap/page.tsx"
}
@@ -21,4 +21,4 @@
"heatmap"
],
"type": "registry:block"
-}
\ No newline at end of file
+}
diff --git a/public/r/logistics-network.json b/public/r/logistics-network.json
index 086e32c..f54e2fb 100644
--- a/public/r/logistics-network.json
+++ b/public/r/logistics-network.json
@@ -27,7 +27,7 @@
},
{
"path": "src/registry/blocks/logistics-network/components/map-arcs.tsx",
- "content": "\"use client\";\n\nimport { useCallback, useEffect, useMemo } from \"react\";\nimport { useMap } from \"@/registry/map\";\nimport type MapLibreGL from \"maplibre-gl\";\nimport { hubs, modeConfig, statusConfig, type Route } from \"../data\";\n\nconst SOURCE_ID = \"logistics-arcs-source\";\nconst LAYER_ID = \"logistics-arcs-layer\";\n\nfunction generateArc(\n start: [number, number],\n end: [number, number],\n segments = 50,\n): number[][] {\n const [x1, y1] = start;\n const [x2, y2] = end;\n\n const mx = (x1 + x2) / 2;\n const my = (y1 + y2) / 2;\n\n const dx = x2 - x1;\n const dy = y2 - y1;\n const dist = Math.sqrt(dx * dx + dy * dy);\n\n const nx = -dy / dist;\n const ny = dx / dist;\n const height = dist * 0.3;\n\n const cx = mx + nx * height;\n const cy = my + ny * height;\n\n const coords: number[][] = [];\n for (let i = 0; i <= segments; i++) {\n const t = i / segments;\n const px = (1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * cx + t * t * x2;\n const py = (1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * cy + t * t * y2;\n coords.push([px, py]);\n }\n return coords;\n}\n\nfunction getHubById(id: string) {\n return hubs.find((h) => h.id === id)!;\n}\n\ninterface MapArcsProps {\n routes: Route[];\n}\n\nexport function MapArcs({ routes: arcRoutes }: MapArcsProps) {\n const { map, isLoaded } = useMap();\n\n const geoJSON = useMemo<GeoJSON.FeatureCollection>(() => {\n const features: GeoJSON.Feature[] = arcRoutes.map((route) => {\n const fromHub = getHubById(route.from);\n const toHub = getHubById(route.to);\n const coordinates = generateArc(\n [fromHub.lng, fromHub.lat],\n [toHub.lng, toHub.lat],\n );\n return {\n type: \"Feature\" as const,\n properties: {\n id: `${route.from}-${route.to}`,\n mode: route.mode,\n status: route.status,\n color:\n route.status === \"delayed\"\n ? statusConfig.delayed.color\n : modeConfig[route.mode].color,\n },\n geometry: {\n type: \"LineString\" as const,\n coordinates,\n },\n };\n });\n return { type: \"FeatureCollection\", features };\n }, [arcRoutes]);\n\n const addLayer = useCallback(() => {\n if (!map) return;\n\n if (!map.getSource(SOURCE_ID)) {\n map.addSource(SOURCE_ID, { type: \"geojson\", data: geoJSON });\n map.addLayer({\n id: LAYER_ID,\n type: \"line\",\n source: SOURCE_ID,\n layout: { \"line-join\": \"round\", \"line-cap\": \"round\" },\n paint: {\n \"line-color\": [\"get\", \"color\"],\n \"line-width\": 2,\n \"line-opacity\": 0.65,\n },\n });\n } else {\n (map.getSource(SOURCE_ID) as MapLibreGL.GeoJSONSource).setData(geoJSON);\n }\n }, [map, geoJSON]);\n\n useEffect(() => {\n if (!map || !isLoaded) return;\n\n addLayer();\n\n return () => {\n try {\n if (map.getLayer(LAYER_ID)) map.removeLayer(LAYER_ID);\n if (map.getSource(SOURCE_ID)) map.removeSource(SOURCE_ID);\n } catch {\n // ignore\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map, isLoaded]);\n\n useEffect(() => {\n if (!map || !isLoaded) return;\n const source = map.getSource(SOURCE_ID) as MapLibreGL.GeoJSONSource;\n if (source) source.setData(geoJSON);\n }, [map, isLoaded, geoJSON]);\n\n return null;\n}\n",
+ "content": "\"use client\";\n\nimport { useCallback, useEffect, useMemo } from \"react\";\nimport { useMap } from \"@/components/ui/map\";\nimport type MapLibreGL from \"maplibre-gl\";\nimport { hubs, modeConfig, statusConfig, type Route } from \"../data\";\n\nconst SOURCE_ID = \"logistics-arcs-source\";\nconst LAYER_ID = \"logistics-arcs-layer\";\n\nfunction generateArc(\n start: [number, number],\n end: [number, number],\n segments = 50,\n): number[][] {\n const [x1, y1] = start;\n const [x2, y2] = end;\n\n const mx = (x1 + x2) / 2;\n const my = (y1 + y2) / 2;\n\n const dx = x2 - x1;\n const dy = y2 - y1;\n const dist = Math.sqrt(dx * dx + dy * dy);\n\n const nx = -dy / dist;\n const ny = dx / dist;\n const height = dist * 0.3;\n\n const cx = mx + nx * height;\n const cy = my + ny * height;\n\n const coords: number[][] = [];\n for (let i = 0; i <= segments; i++) {\n const t = i / segments;\n const px = (1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * cx + t * t * x2;\n const py = (1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * cy + t * t * y2;\n coords.push([px, py]);\n }\n return coords;\n}\n\nfunction getHubById(id: string) {\n return hubs.find((h) => h.id === id)!;\n}\n\ninterface MapArcsProps {\n routes: Route[];\n}\n\nexport function MapArcs({ routes: arcRoutes }: MapArcsProps) {\n const { map, isLoaded } = useMap();\n\n const geoJSON = useMemo<GeoJSON.FeatureCollection>(() => {\n const features: GeoJSON.Feature[] = arcRoutes.map((route) => {\n const fromHub = getHubById(route.from);\n const toHub = getHubById(route.to);\n const coordinates = generateArc(\n [fromHub.lng, fromHub.lat],\n [toHub.lng, toHub.lat],\n );\n return {\n type: \"Feature\" as const,\n properties: {\n id: `${route.from}-${route.to}`,\n mode: route.mode,\n status: route.status,\n color:\n route.status === \"delayed\"\n ? statusConfig.delayed.color\n : modeConfig[route.mode].color,\n },\n geometry: {\n type: \"LineString\" as const,\n coordinates,\n },\n };\n });\n return { type: \"FeatureCollection\", features };\n }, [arcRoutes]);\n\n const addLayer = useCallback(() => {\n if (!map) return;\n\n if (!map.getSource(SOURCE_ID)) {\n map.addSource(SOURCE_ID, { type: \"geojson\", data: geoJSON });\n map.addLayer({\n id: LAYER_ID,\n type: \"line\",\n source: SOURCE_ID,\n layout: { \"line-join\": \"round\", \"line-cap\": \"round\" },\n paint: {\n \"line-color\": [\"get\", \"color\"],\n \"line-width\": 2,\n \"line-opacity\": 0.65,\n },\n });\n } else {\n (map.getSource(SOURCE_ID) as MapLibreGL.GeoJSONSource).setData(geoJSON);\n }\n }, [map, geoJSON]);\n\n useEffect(() => {\n if (!map || !isLoaded) return;\n\n addLayer();\n\n return () => {\n try {\n if (map.getLayer(LAYER_ID)) map.removeLayer(LAYER_ID);\n if (map.getSource(SOURCE_ID)) map.removeSource(SOURCE_ID);\n } catch {\n // ignore\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map, isLoaded]);\n\n useEffect(() => {\n if (!map || !isLoaded) return;\n const source = map.getSource(SOURCE_ID) as MapLibreGL.GeoJSONSource;\n if (source) source.setData(geoJSON);\n }, [map, isLoaded, geoJSON]);\n\n return null;\n}\n",
"type": "registry:component",
"target": "app/logistics/components/map-arcs.tsx"
},
@@ -39,7 +39,7 @@
},
{
"path": "src/registry/blocks/logistics-network/components/network-map.tsx",
- "content": "\"use client\";\n\nimport {\n Map,\n MapControls,\n MapMarker,\n MarkerContent,\n MarkerTooltip,\n} from \"@/registry/map\";\nimport { SidebarTrigger } from \"@/components/ui/sidebar\";\nimport {\n modeConfig,\n regionLabels,\n statusConfig,\n type Hub,\n type Route,\n} from \"../data\";\nimport { MapArcs } from \"./map-arcs\";\nimport { Separator } from \"@/components/ui/separator\";\n\ninterface NetworkMapProps {\n hubs: Hub[];\n routes: Route[];\n}\n\nfunction MapControlsCard() {\n return (\n <div className=\"border-border/40 bg-background/70 absolute top-4 left-4 z-20 flex items-center gap-3 rounded-lg border px-2.5 py-1.5 backdrop-blur-sm\">\n <SidebarTrigger />\n <Separator orientation=\"vertical\" className=\"h-4!\" />\n <div className=\"flex items-center gap-3 text-xs\">\n <div className=\"flex items-center gap-1.5\">\n <span\n className=\"h-0.5 w-4 shrink-0 rounded-full\"\n style={{ backgroundColor: modeConfig.air.color }}\n />\n <span>{modeConfig.air.label}</span>\n </div>\n <div className=\"flex items-center gap-1.5\">\n <span\n className=\"h-0.5 w-4 shrink-0 rounded-full\"\n style={{ backgroundColor: modeConfig.ground.color }}\n />\n <span>{modeConfig.ground.label}</span>\n </div>\n <div className=\"flex items-center gap-1.5\">\n <span\n className=\"h-0.5 w-4 shrink-0 rounded-full\"\n style={{ backgroundColor: statusConfig.delayed.color }}\n />\n <span>{statusConfig.delayed.label}</span>\n </div>\n <div className=\"bg-border h-4 w-px\" />\n <div className=\"flex items-center gap-1.5\">\n <div className=\"size-2.5 shrink-0 rounded-full border border-white bg-blue-500 shadow-sm\" />\n <span>Hub</span>\n </div>\n </div>\n </div>\n );\n}\n\nexport function NetworkMap({ hubs, routes }: NetworkMapProps) {\n return (\n <div className=\"relative h-full\">\n <MapControlsCard />\n\n <Map center={[-98, 39]} zoom={4} projection={{ type: \"globe\" }}>\n <MapControls />\n <MapArcs routes={routes} />\n\n {hubs.map((hub) => (\n <MapMarker key={hub.id} longitude={hub.lng} latitude={hub.lat}>\n <MarkerContent>\n <div className=\"size-3 rounded-full border-2 border-white bg-blue-500 shadow-md\" />\n </MarkerContent>\n <MarkerTooltip\n offset={16}\n className=\"bg-background text-foreground border px-2.5 py-1.5\"\n >\n <p className=\"font-medium\">{hub.city}</p>\n <p className=\"text-muted-foreground mt-1\">\n {hub.shipments.toLocaleString()} shipments\n <span className=\"mx-1.5\">·</span>\n {regionLabels[hub.region]}\n </p>\n </MarkerTooltip>\n </MapMarker>\n ))}\n </Map>\n </div>\n );\n}\n",
+ "content": "\"use client\";\n\nimport {\n Map,\n MapControls,\n MapMarker,\n MarkerContent,\n MarkerTooltip,\n} from \"@/components/ui/map\";\nimport { SidebarTrigger } from \"@/components/ui/sidebar\";\nimport {\n modeConfig,\n regionLabels,\n statusConfig,\n type Hub,\n type Route,\n} from \"../data\";\nimport { MapArcs } from \"./map-arcs\";\nimport { Separator } from \"@/components/ui/separator\";\n\ninterface NetworkMapProps {\n hubs: Hub[];\n routes: Route[];\n}\n\nfunction MapControlsCard() {\n return (\n <div className=\"border-border/40 bg-background/70 absolute top-4 left-4 z-20 flex items-center gap-3 rounded-lg border px-2.5 py-1.5 backdrop-blur-sm\">\n <SidebarTrigger />\n <Separator orientation=\"vertical\" className=\"h-4!\" />\n <div className=\"flex items-center gap-3 text-xs\">\n <div className=\"flex items-center gap-1.5\">\n <span\n className=\"h-0.5 w-4 shrink-0 rounded-full\"\n style={{ backgroundColor: modeConfig.air.color }}\n />\n <span>{modeConfig.air.label}</span>\n </div>\n <div className=\"flex items-center gap-1.5\">\n <span\n className=\"h-0.5 w-4 shrink-0 rounded-full\"\n style={{ backgroundColor: modeConfig.ground.color }}\n />\n <span>{modeConfig.ground.label}</span>\n </div>\n <div className=\"flex items-center gap-1.5\">\n <span\n className=\"h-0.5 w-4 shrink-0 rounded-full\"\n style={{ backgroundColor: statusConfig.delayed.color }}\n />\n <span>{statusConfig.delayed.label}</span>\n </div>\n <div className=\"bg-border h-4 w-px\" />\n <div className=\"flex items-center gap-1.5\">\n <div className=\"size-2.5 shrink-0 rounded-full border border-white bg-blue-500 shadow-sm\" />\n <span>Hub</span>\n </div>\n </div>\n </div>\n );\n}\n\nexport function NetworkMap({ hubs, routes }: NetworkMapProps) {\n return (\n <div className=\"relative h-full\">\n <MapControlsCard />\n\n <Map center={[-98, 39]} zoom={4} projection={{ type: \"globe\" }}>\n <MapControls />\n <MapArcs routes={routes} />\n\n {hubs.map((hub) => (\n <MapMarker key={hub.id} longitude={hub.lng} latitude={hub.lat}>\n <MarkerContent>\n <div className=\"size-3 rounded-full border-2 border-white bg-blue-500 shadow-md\" />\n </MarkerContent>\n <MarkerTooltip\n offset={16}\n className=\"bg-background text-foreground border px-2.5 py-1.5\"\n >\n <p className=\"font-medium\">{hub.city}</p>\n <p className=\"text-muted-foreground mt-1\">\n {hub.shipments.toLocaleString()} shipments\n <span className=\"mx-1.5\">·</span>\n {regionLabels[hub.region]}\n </p>\n </MarkerTooltip>\n </MapMarker>\n ))}\n </Map>\n </div>\n );\n}\n",
"type": "registry:component",
"target": "app/logistics/components/network-map.tsx"
}
@@ -52,4 +52,4 @@
"network"
],
"type": "registry:block"
-}
\ No newline at end of file
+}
diff --git a/public/r/registry.json b/public/r/registry.json
index af7d423..f73e826 100644
--- a/public/r/registry.json
+++ b/public/r/registry.json
@@ -1,7 +1,7 @@
{
"$schema": "https://ui.shadcn.com/schema/registry.json",
"name": "mapcn",
- "homepage": "https://github.com/anmoldeepsingh/mapcn",
+ "homepage": "https://mapcn.dev",
"items": [
{
"name": "map",
diff --git a/registry.json b/registry.json
index af7d423..f73e826 100644
--- a/registry.json
+++ b/registry.json
@@ -1,7 +1,7 @@
{
"$schema": "https://ui.shadcn.com/schema/registry.json",
"name": "mapcn",
- "homepage": "https://github.com/anmoldeepsingh/mapcn",
+ "homepage": "https://mapcn.dev",
"items": [
{
"name": "map",
diff --git a/scripts/fix-registry-imports.ts b/scripts/fix-registry-imports.ts
new file mode 100644
index 0000000..449fbd2
--- /dev/null
+++ b/scripts/fix-registry-imports.ts
@@ -0,0 +1,65 @@
+import fs from "fs";
+import path from "path";
+
+const REGISTRY_DIR = path.join(process.cwd(), "public", "r");
+const FROM_IMPORT = "@/registry/map";
+const TO_IMPORT = "@/components/ui/map";
+
+interface RegistryFile {
+ path: string;
+ content?: string;
+ type?: string;
+ target?: string;
+}
+
+interface RegistryItem {
+ files?: RegistryFile[];
+}
+
+interface RegistryData {
+ files?: RegistryFile[];
+ items?: RegistryItem[];
+}
+
+function fixContent(content: string): string {
+ const escaped = FROM_IMPORT.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+ return content.replace(new RegExp(escaped, "g"), TO_IMPORT);
+}
+
+function processFile(filePath: string): void {
+ const raw = fs.readFileSync(filePath, "utf-8");
+ const data = JSON.parse(raw) as RegistryData;
+ let changed = false;
+
+ if (Array.isArray(data.files)) {
+ for (const file of data.files) {
+ if (file.content?.includes(FROM_IMPORT)) {
+ file.content = fixContent(file.content);
+ changed = true;
+ }
+ }
+ }
+
+ if (Array.isArray(data.items)) {
+ for (const item of data.items) {
+ if (Array.isArray(item.files)) {
+ for (const file of item.files) {
+ if (file.content?.includes(FROM_IMPORT)) {
+ file.content = fixContent(file.content);
+ changed = true;
+ }
+ }
+ }
+ }
+ }
+
+ if (changed) {
+ fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + "\n", "utf-8");
+ console.log("Fixed imports in:", path.relative(process.cwd(), filePath));
+ }
+}
+
+const files = fs.readdirSync(REGISTRY_DIR).filter((f) => f.endsWith(".json"));
+for (const f of files) {
+ processFile(path.join(REGISTRY_DIR, f));
+}