birdclaw 0.8.3 → 0.8.4

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.
Files changed (284) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +10 -8
  3. package/bin/birdclaw.mjs +4 -66
  4. package/dist/cli/birdclaw.js +28165 -0
  5. package/dist/client/assets/AvatarChip-DLoqM5xD.js +1 -0
  6. package/dist/client/assets/ProfilePreview-BejAuYsJ.js +1 -0
  7. package/dist/client/assets/SavedTimelineView-BIS7HKpp.js +1 -0
  8. package/dist/client/assets/SmartTimestamp-BR0-9se2.js +1 -0
  9. package/dist/client/assets/TimelineRouteFrame-CyGPj0eM.js +1 -0
  10. package/dist/client/assets/blocks-7UDKQp8H.js +1 -0
  11. package/dist/client/assets/bookmarks-CbBkMvXk.js +1 -0
  12. package/dist/client/assets/chunk-C0phanGV.js +1 -0
  13. package/dist/client/assets/circle-check-C_Vq3ElD.js +1 -0
  14. package/dist/client/assets/client-stream-contracts-ys3XhWG4.js +5 -0
  15. package/dist/client/assets/createLucideIcon-JV8isFFR.js +1 -0
  16. package/dist/client/assets/data-sources-Cm2bpNvg.js +1 -0
  17. package/dist/client/assets/discuss-DTjaOugw.js +1 -0
  18. package/dist/client/assets/dms-CGd6Eogq.js +1 -0
  19. package/dist/client/assets/inbox-BHlGuOy2.js +1 -0
  20. package/dist/client/assets/index-CEIG7S6s.js +31 -0
  21. package/dist/client/assets/index-bpFrQ5yG.css +1 -0
  22. package/dist/client/assets/likes-cLrcAQem.js +1 -0
  23. package/dist/client/assets/links-CM9QO1LC.js +1 -0
  24. package/dist/client/assets/mapbox-BxTlqXt9.js +2 -0
  25. package/dist/client/assets/mapbox-gl-dgf_hX3a.js +3215 -0
  26. package/dist/client/assets/mentions-CxKCgzIf.js +1 -0
  27. package/dist/client/assets/network-map-B5a3whqj.js +2 -0
  28. package/dist/client/assets/profile-analyze-CRtNEwlb.js +1 -0
  29. package/dist/client/assets/profile-hydration-client-YEtJsNTv.js +1 -0
  30. package/dist/client/assets/profiles._handle-C82_HoKX.js +1 -0
  31. package/dist/client/assets/query-client-fYu2rzRC.js +17 -0
  32. package/dist/client/assets/rate-limits-ScaEwdVK.js +1 -0
  33. package/dist/client/assets/react-dom-DHl6Ug7F.js +1 -0
  34. package/dist/client/assets/react-nBylq1U5.js +1 -0
  35. package/dist/client/assets/repeat-2-xCwHM9hD.js +1 -0
  36. package/dist/client/assets/routes-q7ZaW4En.js +1 -0
  37. package/dist/client/assets/schemas-I9r6F6ya.js +64 -0
  38. package/dist/client/assets/search-Dq5kYsxA.js +1 -0
  39. package/dist/client/assets/sparkles-CQVlvHsZ.js +1 -0
  40. package/dist/client/assets/styles-B8s3tt3r.css +2 -0
  41. package/dist/client/assets/today-CeG1O7Py.js +1 -0
  42. package/dist/client/assets/triangle-alert-CBL7s2pf.js +1 -0
  43. package/dist/client/assets/useTimelineRouteData-1HsqgvUi.js +1 -0
  44. package/dist/client/assets/users-CHbKlqUr.js +1 -0
  45. package/dist/server/assets/AvatarChip-zUDAEmjL.js +105 -0
  46. package/dist/server/assets/FeedState-ntW0Q2GB.js +214 -0
  47. package/dist/server/assets/ProfileAnalysisStream-BFvhVdhn.js +198 -0
  48. package/dist/server/assets/ProfilePreview-C6gAor_j.js +752 -0
  49. package/dist/server/assets/SavedTimelineView-BG1jnBp1.js +64 -0
  50. package/dist/server/assets/SmartTimestamp-DfwE1NGf.js +45 -0
  51. package/dist/server/assets/SyncNowButton-BOn_IBXS.js +76 -0
  52. package/dist/server/assets/TimelineRouteFrame-CU7ilM7U.js +85 -0
  53. package/dist/server/assets/TweetRichText-DhCVv1-6.js +74 -0
  54. package/dist/server/assets/_tanstack-start-manifest_v-C-ZRnG_n.js +148 -0
  55. package/dist/server/assets/account-selection-CTdFGWRk.js +44 -0
  56. package/dist/server/assets/blocks-C1mgGTB3.js +299 -0
  57. package/dist/server/assets/blocks-DSgQghqP.js +17 -0
  58. package/dist/server/assets/bookmarks-BJN8tykY.js +14 -0
  59. package/dist/server/assets/client-stream-contracts-C2xbWVjm.js +769 -0
  60. package/dist/server/assets/data-sources-BnA1Q94p.js +180 -0
  61. package/dist/server/assets/discuss-CJ1dau1j.js +15 -0
  62. package/dist/server/assets/discuss-QTo08NCN.js +338 -0
  63. package/dist/server/assets/dms-BuLj4bp8.js +368 -0
  64. package/dist/server/assets/dms-DAyQrVM2.js +240 -0
  65. package/dist/server/assets/empty-plugin-adapters-DzrEkdBF.js +5 -0
  66. package/dist/server/assets/inbox-CkGOaW1q.js +214 -0
  67. package/dist/server/assets/inbox-DpWd1EzC.js +146 -0
  68. package/dist/server/assets/likes-DBOAtsJU.js +14 -0
  69. package/dist/server/assets/links-DAhSjynu.js +240 -0
  70. package/dist/server/assets/links-DmH5lxHO.js +468 -0
  71. package/dist/server/assets/mentions-BH2MzKtB.js +26 -0
  72. package/dist/server/assets/network-map-D3CzRcC4.js +224 -0
  73. package/dist/server/assets/network-map-D5DoLOwR.js +582 -0
  74. package/dist/server/assets/profile-analyze-BP65PED0.js +90 -0
  75. package/dist/server/assets/profile-analyze-C1NoM0tV.js +9 -0
  76. package/dist/server/assets/profile-hydration-client-GJ4kwJS8.js +133 -0
  77. package/dist/server/assets/profiles._handle-DjwlN_ac.js +184 -0
  78. package/dist/server/assets/profiles._handle-DsLNj2Ca.js +12 -0
  79. package/dist/server/assets/query-client-BdauHBgd.js +923 -0
  80. package/dist/server/assets/rate-limits-VAr2qzYD.js +262 -0
  81. package/dist/server/assets/route-search-BUlQ5lGM.js +117 -0
  82. package/dist/server/assets/router-DqkwSPiM.js +17026 -0
  83. package/dist/server/assets/routes-A9c9ZhwN.js +26 -0
  84. package/dist/server/assets/start-FaDOTmto.js +4 -0
  85. package/dist/server/assets/today-B5hVM57Z.js +17 -0
  86. package/dist/server/assets/today-fvGiZ7ud.js +303 -0
  87. package/dist/server/assets/ui-qbmcMSSX.js +137 -0
  88. package/{src/components/useDebouncedValue.ts → dist/server/assets/useDebouncedValue-DOnA6Xcy.js} +4 -4
  89. package/dist/server/assets/useTimelineRouteData-27cxynxa.js +1101 -0
  90. package/dist/server/server.js +5520 -0
  91. package/package.json +26 -34
  92. package/playwright.config.ts +0 -35
  93. package/scripts/browser-perf.mjs +0 -427
  94. package/scripts/build-docs-site.mjs +0 -967
  95. package/scripts/docs-site-assets.mjs +0 -311
  96. package/scripts/run-vitest.mjs +0 -21
  97. package/scripts/sanitize-node-options.mjs +0 -23
  98. package/scripts/start-test-server.mjs +0 -42
  99. package/src/cli/command-context.ts +0 -17
  100. package/src/cli/register-analysis.ts +0 -500
  101. package/src/cli/register-compose.ts +0 -40
  102. package/src/cli/register-graph.ts +0 -132
  103. package/src/cli/register-inbox.ts +0 -41
  104. package/src/cli/register-storage.ts +0 -106
  105. package/src/cli-moderation.ts +0 -210
  106. package/src/cli.ts +0 -1616
  107. package/src/components/AccountSwitcher.tsx +0 -178
  108. package/src/components/AppNav.tsx +0 -118
  109. package/src/components/AvatarChip.tsx +0 -58
  110. package/src/components/AvatarPreload.ts +0 -149
  111. package/src/components/BrandMark.tsx +0 -67
  112. package/src/components/ConversationThread.tsx +0 -131
  113. package/src/components/DmWorkspace.tsx +0 -286
  114. package/src/components/EmbeddedTweetCard.tsx +0 -55
  115. package/src/components/FeedState.tsx +0 -147
  116. package/src/components/FloatingPreview.tsx +0 -382
  117. package/src/components/InboxCard.tsx +0 -152
  118. package/src/components/LinkPreviewCard.tsx +0 -292
  119. package/src/components/MarkdownCitations.tsx +0 -680
  120. package/src/components/MarkdownViewer.tsx +0 -111
  121. package/src/components/ProfileAnalysisClient.ts +0 -191
  122. package/src/components/ProfileAnalysisStream.tsx +0 -259
  123. package/src/components/ProfilePreview.tsx +0 -131
  124. package/src/components/SavedTimelineView.tsx +0 -155
  125. package/src/components/SmartTimestamp.tsx +0 -72
  126. package/src/components/SyncNowButton.tsx +0 -140
  127. package/src/components/ThemeSlider.tsx +0 -80
  128. package/src/components/TimelineCard.tsx +0 -533
  129. package/src/components/TimelineRouteFrame.tsx +0 -186
  130. package/src/components/TweetArticleCard.tsx +0 -66
  131. package/src/components/TweetMediaGrid.tsx +0 -185
  132. package/src/components/TweetRichText.tsx +0 -159
  133. package/src/components/account-selection.ts +0 -64
  134. package/src/components/links-controller.ts +0 -162
  135. package/src/components/links-model.ts +0 -198
  136. package/src/components/network-map-controller.ts +0 -84
  137. package/src/components/network-map-model.ts +0 -255
  138. package/src/components/useTimelineRouteData.ts +0 -193
  139. package/src/lib/account-sync-job.ts +0 -666
  140. package/src/lib/actions-transport.ts +0 -300
  141. package/src/lib/analysis-runtime.ts +0 -238
  142. package/src/lib/api-client.ts +0 -220
  143. package/src/lib/api-contracts.ts +0 -328
  144. package/src/lib/archive-finder.ts +0 -185
  145. package/src/lib/archive-import-plan.ts +0 -102
  146. package/src/lib/archive-import.ts +0 -2695
  147. package/src/lib/authored-live.ts +0 -1027
  148. package/src/lib/avatar-cache.ts +0 -349
  149. package/src/lib/backup.ts +0 -2652
  150. package/src/lib/bird-actions.ts +0 -294
  151. package/src/lib/bird-command.ts +0 -130
  152. package/src/lib/bird.ts +0 -1140
  153. package/src/lib/blocklist.ts +0 -136
  154. package/src/lib/blocks-write.ts +0 -171
  155. package/src/lib/blocks.ts +0 -387
  156. package/src/lib/bookmark-sync-job.ts +0 -536
  157. package/src/lib/config.ts +0 -224
  158. package/src/lib/conversation-surface.ts +0 -205
  159. package/src/lib/data-sources.ts +0 -219
  160. package/src/lib/database-metrics.ts +0 -88
  161. package/src/lib/database-migrations.ts +0 -34
  162. package/src/lib/database-schema.ts +0 -312
  163. package/src/lib/database-writer.ts +0 -69
  164. package/src/lib/db.ts +0 -889
  165. package/src/lib/dm-read-model.ts +0 -533
  166. package/src/lib/dms-live.ts +0 -870
  167. package/src/lib/effect-runtime.ts +0 -45
  168. package/src/lib/follow-graph.ts +0 -1087
  169. package/src/lib/geocoding.ts +0 -296
  170. package/src/lib/http-effect.ts +0 -222
  171. package/src/lib/identity-search-index.ts +0 -369
  172. package/src/lib/import-repository.ts +0 -138
  173. package/src/lib/inbox.ts +0 -242
  174. package/src/lib/link-index.ts +0 -641
  175. package/src/lib/link-insights.ts +0 -860
  176. package/src/lib/link-preview-metadata.ts +0 -754
  177. package/src/lib/live-sync-engine.ts +0 -209
  178. package/src/lib/live-transport-gateway.ts +0 -128
  179. package/src/lib/location.ts +0 -137
  180. package/src/lib/media-fetch.ts +0 -860
  181. package/src/lib/media-includes.ts +0 -165
  182. package/src/lib/mention-threads-live.ts +0 -830
  183. package/src/lib/mentions-export.ts +0 -147
  184. package/src/lib/mentions-live.ts +0 -1114
  185. package/src/lib/moderation-target.ts +0 -227
  186. package/src/lib/moderation-write.ts +0 -131
  187. package/src/lib/mutes-write.ts +0 -171
  188. package/src/lib/mutes.ts +0 -84
  189. package/src/lib/ndjson-stream.ts +0 -106
  190. package/src/lib/network-map.ts +0 -382
  191. package/src/lib/openai-response-runtime.ts +0 -251
  192. package/src/lib/openai.ts +0 -117
  193. package/src/lib/paginated-sync.ts +0 -93
  194. package/src/lib/period-digest.ts +0 -1364
  195. package/src/lib/present.ts +0 -118
  196. package/src/lib/profile-affiliation-hydration.ts +0 -228
  197. package/src/lib/profile-affiliations.ts +0 -262
  198. package/src/lib/profile-analysis.ts +0 -1198
  199. package/src/lib/profile-bio-entities.ts +0 -318
  200. package/src/lib/profile-history.ts +0 -164
  201. package/src/lib/profile-hydration.ts +0 -180
  202. package/src/lib/profile-replies.ts +0 -77
  203. package/src/lib/profile-resolver.ts +0 -650
  204. package/src/lib/queries.ts +0 -6
  205. package/src/lib/query-actions.ts +0 -437
  206. package/src/lib/query-client.tsx +0 -47
  207. package/src/lib/query-read-model-shared.ts +0 -52
  208. package/src/lib/query-read-models.ts +0 -5
  209. package/src/lib/query-resource.ts +0 -41
  210. package/src/lib/query-status.ts +0 -164
  211. package/src/lib/research.ts +0 -652
  212. package/src/lib/runtime-services.ts +0 -20
  213. package/src/lib/search-discussion.ts +0 -812
  214. package/src/lib/seed.ts +0 -613
  215. package/src/lib/server-runtime-services.ts +0 -30
  216. package/src/lib/sqlite.ts +0 -183
  217. package/src/lib/streaming-ingestion.ts +0 -240
  218. package/src/lib/sync-cache.ts +0 -70
  219. package/src/lib/sync-plan.ts +0 -175
  220. package/src/lib/theme-transition.ts +0 -113
  221. package/src/lib/theme.tsx +0 -165
  222. package/src/lib/timeline-collections-live.ts +0 -407
  223. package/src/lib/timeline-live.ts +0 -302
  224. package/src/lib/timeline-read-model.ts +0 -1191
  225. package/src/lib/tweet-account-edges.ts +0 -48
  226. package/src/lib/tweet-lookup.ts +0 -46
  227. package/src/lib/tweet-render.ts +0 -430
  228. package/src/lib/tweet-repository.ts +0 -156
  229. package/src/lib/tweet-search-live.ts +0 -462
  230. package/src/lib/types.ts +0 -723
  231. package/src/lib/ui.ts +0 -529
  232. package/src/lib/url-expansion-store.ts +0 -110
  233. package/src/lib/url-expansion.ts +0 -343
  234. package/src/lib/url-safety.ts +0 -220
  235. package/src/lib/web-sync.ts +0 -533
  236. package/src/lib/whois.ts +0 -1080
  237. package/src/lib/x-profile.ts +0 -365
  238. package/src/lib/x-web.ts +0 -199
  239. package/src/lib/xurl-rate-limits.ts +0 -267
  240. package/src/lib/xurl.ts +0 -1677
  241. package/src/routeTree.gen.ts +0 -723
  242. package/src/router.tsx +0 -20
  243. package/src/routes/__root.tsx +0 -82
  244. package/src/routes/api/action.tsx +0 -147
  245. package/src/routes/api/avatar.tsx +0 -50
  246. package/src/routes/api/blocks.tsx +0 -35
  247. package/src/routes/api/conversation.tsx +0 -45
  248. package/src/routes/api/data-sources.tsx +0 -24
  249. package/src/routes/api/inbox.tsx +0 -43
  250. package/src/routes/api/link-insights.tsx +0 -85
  251. package/src/routes/api/link-preview.tsx +0 -47
  252. package/src/routes/api/network-map.tsx +0 -55
  253. package/src/routes/api/period-digest.tsx +0 -101
  254. package/src/routes/api/profile-analysis.tsx +0 -97
  255. package/src/routes/api/profile-hydrate.tsx +0 -54
  256. package/src/routes/api/query.tsx +0 -121
  257. package/src/routes/api/search-discussion.tsx +0 -113
  258. package/src/routes/api/status.tsx +0 -30
  259. package/src/routes/api/sync.tsx +0 -108
  260. package/src/routes/api/xurl-rate-limits.tsx +0 -24
  261. package/src/routes/blocks.tsx +0 -343
  262. package/src/routes/bookmarks.tsx +0 -18
  263. package/src/routes/data-sources.tsx +0 -249
  264. package/src/routes/discuss.tsx +0 -419
  265. package/src/routes/dms.tsx +0 -415
  266. package/src/routes/inbox.tsx +0 -232
  267. package/src/routes/index.tsx +0 -32
  268. package/src/routes/likes.tsx +0 -18
  269. package/src/routes/links.tsx +0 -631
  270. package/src/routes/mentions.tsx +0 -32
  271. package/src/routes/network-map.tsx +0 -732
  272. package/src/routes/profile-analyze.tsx +0 -112
  273. package/src/routes/profiles.$handle.tsx +0 -228
  274. package/src/routes/rate-limits.tsx +0 -305
  275. package/src/routes/today.tsx +0 -511
  276. package/src/styles.css +0 -257
  277. package/tsconfig.json +0 -29
  278. package/vite.config.ts +0 -29
  279. /package/{public → dist/client}/birdclaw-mark.png +0 -0
  280. /package/{public → dist/client}/favicon.ico +0 -0
  281. /package/{public → dist/client}/logo192.png +0 -0
  282. /package/{public → dist/client}/logo512.png +0 -0
  283. /package/{public → dist/client}/manifest.json +0 -0
  284. /package/{public → dist/client}/robots.txt +0 -0
@@ -1,732 +0,0 @@
1
- import { createFileRoute } from "@tanstack/react-router";
2
- import {
3
- Globe2,
4
- MapPin,
5
- RefreshCw,
6
- Search,
7
- Users,
8
- WifiOff,
9
- } from "lucide-react";
10
- import {
11
- type CSSProperties,
12
- useCallback,
13
- useEffect,
14
- useMemo,
15
- useRef,
16
- useState,
17
- } from "react";
18
- import "mapbox-gl/dist/mapbox-gl.css";
19
- import type { MapRef } from "react-map-gl/mapbox";
20
- import { useNetworkMapController } from "#/components/network-map-controller";
21
- import type { NetworkMapResponse } from "#/lib/network-map";
22
- import {
23
- cx,
24
- errorCopyClass,
25
- pageHeaderActionsClass,
26
- pageHeaderClass,
27
- pageHeaderRowClass,
28
- pageSubtitleClass,
29
- pageTitleClass,
30
- secondaryButtonClass,
31
- segmentedClass,
32
- segmentActiveClass,
33
- segmentClass,
34
- searchFieldIconClass,
35
- searchFieldInputClass,
36
- searchFieldShellClass,
37
- statusCopyClass,
38
- } from "#/lib/ui";
39
-
40
- import {
41
- CLUSTER_LEAF_SAMPLE_SIZE,
42
- WORLD_VIEWPORT,
43
- type ClusterAggregateProperties,
44
- type ClusterResult,
45
- type MapFeature,
46
- type MapViewport,
47
- type ReactMapboxModule,
48
- type SelectedOverlay,
49
- avatarInitial,
50
- avatarPath,
51
- buildClusterIndex,
52
- clusterGradient,
53
- compareClusterFeatures,
54
- formatNumber,
55
- formatRelationship,
56
- getClusterDisplayAnchor,
57
- isCluster,
58
- readViewport,
59
- relationshipColor,
60
- } from "#/components/network-map-model";
61
-
62
- export const Route = createFileRoute("/network-map")({
63
- component: NetworkMapRoute,
64
- });
65
-
66
- function StatTile({
67
- icon: Icon,
68
- label,
69
- value,
70
- }: {
71
- icon: typeof Users;
72
- label: string;
73
- value: number;
74
- }) {
75
- return (
76
- <div className="flex min-w-0 flex-col gap-2 border-b border-[var(--line)] px-4 py-3 sm:border-r">
77
- <div className="flex items-center gap-2 text-[13px] font-medium text-[var(--ink-soft)]">
78
- <Icon className="size-4" strokeWidth={1.8} />
79
- <span>{label}</span>
80
- </div>
81
- <div className="truncate text-[24px] font-bold tracking-tight text-[var(--ink)]">
82
- {formatNumber(value)}
83
- </div>
84
- </div>
85
- );
86
- }
87
-
88
- function useMapboxModule() {
89
- const [module, setModule] = useState<ReactMapboxModule | null>(null);
90
- const [error, setError] = useState<string | null>(null);
91
-
92
- useEffect(() => {
93
- let cancelled = false;
94
- import("react-map-gl/mapbox")
95
- .then((loaded) => {
96
- if (!cancelled) setModule(loaded);
97
- })
98
- .catch((cause: unknown) => {
99
- if (!cancelled) {
100
- setError(cause instanceof Error ? cause.message : "Map failed");
101
- }
102
- });
103
- return () => {
104
- cancelled = true;
105
- };
106
- }, []);
107
-
108
- return { module, error };
109
- }
110
-
111
- function Avatar({
112
- feature,
113
- size = 36,
114
- className,
115
- style,
116
- }: {
117
- feature: MapFeature;
118
- size?: number;
119
- className?: string;
120
- style?: CSSProperties;
121
- }) {
122
- const src = avatarPath(feature);
123
- const [failedSrc, setFailedSrc] = useState<string | null>(null);
124
- const showImage = src && failedSrc !== src;
125
- return (
126
- <div
127
- className={cx(
128
- "relative grid shrink-0 place-items-center overflow-hidden rounded-full bg-[var(--accent-soft)] text-[12px] font-bold text-[var(--accent)] ring-2 ring-white",
129
- className,
130
- )}
131
- style={{ width: size, height: size, ...style }}
132
- >
133
- {showImage ? (
134
- <img
135
- src={src}
136
- alt=""
137
- className="h-full w-full object-cover"
138
- loading="lazy"
139
- onError={() => setFailedSrc(src)}
140
- />
141
- ) : (
142
- <span>{avatarInitial(feature)}</span>
143
- )}
144
- </div>
145
- );
146
- }
147
-
148
- function ProfileMarker({ feature }: { feature: MapFeature }) {
149
- const color = relationshipColor(feature.properties.relationship);
150
- return (
151
- <button
152
- type="button"
153
- className="group relative grid size-11 place-items-center rounded-full border-0 bg-transparent p-0 transition-transform hover:z-10 hover:scale-110"
154
- aria-label={`Open @${feature.properties.handle}`}
155
- title={`@${feature.properties.handle}`}
156
- >
157
- <span
158
- className="absolute inset-0 rounded-full opacity-90 shadow-[0_10px_28px_rgba(15,20,25,0.28)]"
159
- style={{ backgroundColor: color }}
160
- />
161
- <Avatar feature={feature} size={34} className="relative ring-[3px]" />
162
- </button>
163
- );
164
- }
165
-
166
- function ClusterMarker({
167
- count,
168
- features,
169
- stats,
170
- }: {
171
- count: number;
172
- features: MapFeature[];
173
- stats: ClusterAggregateProperties;
174
- }) {
175
- const size = Math.min(82, Math.max(52, 44 + Math.log2(count) * 7));
176
- const avatarSize = size >= 72 ? 30 : 25;
177
- return (
178
- <button
179
- type="button"
180
- className="group relative rounded-full border-0 bg-transparent p-0 transition-transform hover:z-10 hover:scale-105"
181
- aria-label={`${formatNumber(count)} located profiles`}
182
- title={`${formatNumber(count)} profiles`}
183
- style={{ width: size, height: size }}
184
- >
185
- <span
186
- className="absolute inset-0 rounded-full opacity-95 shadow-[0_18px_42px_rgba(15,20,25,0.32)]"
187
- style={{ background: clusterGradient(stats) }}
188
- />
189
- <span className="absolute inset-[4px] rounded-full bg-white/88 backdrop-blur-sm" />
190
- <span className="absolute inset-0 flex items-center justify-center">
191
- {features.slice(0, 4).map((feature, index) => (
192
- <Avatar
193
- key={feature.properties.profileId}
194
- feature={feature}
195
- size={avatarSize}
196
- className="absolute"
197
- style={{
198
- transform: `translate(${[-10, 10, -7, 8][index] ?? 0}px, ${[-9, -8, 11, 10][index] ?? 0}px)`,
199
- }}
200
- />
201
- ))}
202
- </span>
203
- <span className="absolute -right-1 -top-1 min-w-7 rounded-full bg-[#0f1419] px-1.5 py-0.5 text-center text-[11px] font-bold leading-5 text-white ring-2 ring-white">
204
- {count > 99 ? "99+" : formatNumber(count)}
205
- </span>
206
- </button>
207
- );
208
- }
209
-
210
- function MapboxPanel({
211
- data,
212
- onViewportChange,
213
- }: {
214
- data: NetworkMapResponse;
215
- onViewportChange: (viewport: MapViewport) => void;
216
- }) {
217
- const { module, error } = useMapboxModule();
218
- const mapRef = useRef<MapRef | null>(null);
219
- const [viewport, setViewport] = useState<MapViewport>(WORLD_VIEWPORT);
220
- const [selected, setSelected] = useState<SelectedOverlay | null>(null);
221
-
222
- const clusterIndex = useMemo(() => buildClusterIndex(data.features), [data]);
223
- const visibleClusters = useMemo(
224
- () =>
225
- clusterIndex.getClusters(
226
- viewport.bounds,
227
- Math.max(0, Math.floor(viewport.zoom)),
228
- ) as ClusterResult[],
229
- [clusterIndex, viewport],
230
- );
231
-
232
- useEffect(() => {
233
- setSelected(null);
234
- }, [data]);
235
-
236
- const updateViewport = useCallback(
237
- (event: { target: unknown }) => {
238
- const next = readViewport(event.target);
239
- if (!next) return;
240
- setViewport(next);
241
- onViewportChange(next);
242
- },
243
- [onViewportChange],
244
- );
245
-
246
- if (!data.config.mapboxToken) {
247
- return <SvgMapFallback data={data} />;
248
- }
249
- if (error) {
250
- return (
251
- <div className={statusCopyClass}>
252
- <WifiOff className="mr-2 inline size-4" strokeWidth={1.8} />
253
- {error}
254
- </div>
255
- );
256
- }
257
- if (!module) {
258
- return <div className={statusCopyClass}>Loading map...</div>;
259
- }
260
-
261
- const { default: Map, Marker, NavigationControl, Popup } = module;
262
- const style =
263
- document.documentElement.dataset.theme === "dark"
264
- ? "mapbox://styles/mapbox/dark-v11"
265
- : "mapbox://styles/mapbox/light-v11";
266
-
267
- return (
268
- <div className="min-h-[520px] flex-1 overflow-hidden bg-[var(--bg-active)] min-[1180px]:min-h-0">
269
- <Map
270
- ref={mapRef}
271
- initialViewState={{ longitude: 9, latitude: 24, zoom: 1.2 }}
272
- mapStyle={style}
273
- mapboxAccessToken={data.config.mapboxToken}
274
- onClick={() => setSelected(null)}
275
- onLoad={updateViewport}
276
- onMoveEnd={updateViewport}
277
- projection="mercator"
278
- style={{ width: "100%", height: "100%" }}
279
- >
280
- <NavigationControl position="top-right" showCompass={false} />
281
- {visibleClusters.map((item) => {
282
- const [longitude, latitude] = item.geometry.coordinates;
283
- if (isCluster(item)) {
284
- const fallbackCoordinates = item.geometry.coordinates as [
285
- number,
286
- number,
287
- ];
288
- const leaves = clusterIndex
289
- .getLeaves(item.properties.cluster_id, CLUSTER_LEAF_SAMPLE_SIZE)
290
- .map((leaf) => data.features[leaf.properties.featureIndex])
291
- .filter((feature): feature is MapFeature => Boolean(feature))
292
- .sort(compareClusterFeatures);
293
- const [displayLongitude, displayLatitude] = getClusterDisplayAnchor(
294
- leaves,
295
- fallbackCoordinates,
296
- );
297
- return (
298
- <Marker
299
- key={`cluster-${String(item.properties.cluster_id)}`}
300
- longitude={displayLongitude}
301
- latitude={displayLatitude}
302
- anchor="center"
303
- onClick={(event: { originalEvent?: Event }) => {
304
- event.originalEvent?.stopPropagation();
305
- const expansionZoom = Math.min(
306
- clusterIndex.getClusterExpansionZoom(
307
- item.properties.cluster_id,
308
- ),
309
- 12,
310
- );
311
- mapRef.current?.flyTo?.({
312
- center: [displayLongitude, displayLatitude],
313
- zoom: Math.max(viewport.zoom + 0.85, expansionZoom - 0.6),
314
- duration: 520,
315
- });
316
- setSelected({
317
- kind: "cluster",
318
- coordinates: [displayLongitude, displayLatitude],
319
- count: item.properties.point_count,
320
- features: leaves,
321
- stats: item.properties,
322
- });
323
- }}
324
- >
325
- <ClusterMarker
326
- count={item.properties.point_count}
327
- features={leaves}
328
- stats={item.properties}
329
- />
330
- </Marker>
331
- );
332
- }
333
- const feature = data.features[item.properties.featureIndex];
334
- if (!feature) return null;
335
- return (
336
- <Marker
337
- key={feature.properties.profileId}
338
- longitude={longitude}
339
- latitude={latitude}
340
- anchor="center"
341
- onClick={(event: { originalEvent?: Event }) => {
342
- event.originalEvent?.stopPropagation();
343
- setSelected({ kind: "profile", feature });
344
- }}
345
- >
346
- <ProfileMarker feature={feature} />
347
- </Marker>
348
- );
349
- })}
350
- {selected ? (
351
- <Popup
352
- longitude={
353
- selected.kind === "profile"
354
- ? selected.feature.geometry.coordinates[0]
355
- : selected.coordinates[0]
356
- }
357
- latitude={
358
- selected.kind === "profile"
359
- ? selected.feature.geometry.coordinates[1]
360
- : selected.coordinates[1]
361
- }
362
- closeButton={false}
363
- offset={12}
364
- onClose={() => setSelected(null)}
365
- >
366
- {selected.kind === "profile" ? (
367
- <ProfilePopup feature={selected.feature} />
368
- ) : (
369
- <ClusterPopup
370
- count={selected.count}
371
- features={selected.features}
372
- stats={selected.stats}
373
- />
374
- )}
375
- </Popup>
376
- ) : null}
377
- </Map>
378
- </div>
379
- );
380
- }
381
-
382
- function SvgMapFallback({ data }: { data: NetworkMapResponse }) {
383
- const points = data.features.slice(0, 1500).map((feature) => {
384
- const [lng, lat] = feature.geometry.coordinates;
385
- return {
386
- feature,
387
- x: ((lng + 180) / 360) * 1000,
388
- y: ((90 - lat) / 180) * 500,
389
- };
390
- });
391
- return (
392
- <div className="border-b border-[var(--line)] bg-[var(--bg-active)] px-4 py-4">
393
- <svg
394
- viewBox="0 0 1000 500"
395
- className="h-auto w-full rounded-md border border-[var(--line)] bg-[var(--bg)]"
396
- role="img"
397
- aria-label="Network map"
398
- >
399
- <defs>
400
- <pattern
401
- id="map-grid"
402
- width="100"
403
- height="100"
404
- patternUnits="userSpaceOnUse"
405
- >
406
- <path
407
- d="M 100 0 L 0 0 0 100"
408
- fill="none"
409
- stroke="currentColor"
410
- strokeOpacity="0.08"
411
- strokeWidth="1"
412
- />
413
- </pattern>
414
- </defs>
415
- <rect width="1000" height="500" fill="url(#map-grid)" />
416
- <path
417
- d="M60 205 C145 155 210 145 280 178 C352 212 424 186 495 194 C594 206 665 157 746 178 C836 201 907 227 952 282"
418
- fill="none"
419
- stroke="currentColor"
420
- strokeOpacity="0.18"
421
- strokeWidth="36"
422
- strokeLinecap="round"
423
- />
424
- {points.map(({ feature, x, y }) => (
425
- <circle
426
- key={feature.properties.profileId}
427
- cx={x}
428
- cy={y}
429
- r={feature.properties.relationship === "mutual" ? 4.5 : 3.5}
430
- fill={
431
- feature.properties.relationship === "mutual"
432
- ? "#22c55e"
433
- : feature.properties.relationship === "following"
434
- ? "#f59e0b"
435
- : "#1d9bf0"
436
- }
437
- opacity="0.86"
438
- />
439
- ))}
440
- </svg>
441
- </div>
442
- );
443
- }
444
-
445
- function ProfilePopup({ feature }: { feature: MapFeature }) {
446
- return (
447
- <div className="flex max-w-[280px] gap-3 text-[13px] text-[#0f1419]">
448
- <Avatar feature={feature} size={48} className="ring-[#d9e2ea]" />
449
- <div className="min-w-0">
450
- <div className="truncate font-bold">{feature.properties.name}</div>
451
- <div className="truncate text-[#536471]">
452
- @{feature.properties.handle}
453
- </div>
454
- <div className="mt-1 line-clamp-2">{feature.properties.location}</div>
455
- {feature.properties.resolvedLocation ? (
456
- <div className="truncate text-[#536471]">
457
- {feature.properties.resolvedLocation}
458
- </div>
459
- ) : null}
460
- </div>
461
- </div>
462
- );
463
- }
464
-
465
- function ClusterPopup({
466
- count,
467
- features,
468
- stats,
469
- }: {
470
- count: number;
471
- features: MapFeature[];
472
- stats: ClusterAggregateProperties;
473
- }) {
474
- return (
475
- <div className="w-[290px] text-[13px] text-[#0f1419]">
476
- <div className="flex items-center justify-between gap-3">
477
- <div>
478
- <div className="font-bold">{formatNumber(count)} profiles here</div>
479
- <div className="text-[#536471]">
480
- {formatNumber(stats.mutual)} mutual ·{" "}
481
- {formatNumber(stats.following)} following ·{" "}
482
- {formatNumber(stats.followers)} followers
483
- </div>
484
- </div>
485
- <div
486
- className="size-11 shrink-0 rounded-full ring-2 ring-[#d9e2ea]"
487
- style={{ background: clusterGradient(stats) }}
488
- />
489
- </div>
490
- <div className="mt-3 flex -space-x-2">
491
- {features.slice(0, 6).map((feature) => (
492
- <Avatar
493
- key={feature.properties.profileId}
494
- feature={feature}
495
- size={36}
496
- className="ring-[#ffffff]"
497
- />
498
- ))}
499
- </div>
500
- <div className="mt-3 divide-y divide-[#eff3f4]">
501
- {features.slice(0, 5).map((feature) => (
502
- <div
503
- key={feature.properties.profileId}
504
- className="flex min-w-0 items-center gap-2 py-2"
505
- >
506
- <Avatar feature={feature} size={28} className="ring-[#ffffff]" />
507
- <div className="min-w-0 flex-1">
508
- <div className="truncate font-semibold">
509
- {feature.properties.name}
510
- </div>
511
- <div className="truncate text-[#536471]">
512
- @{feature.properties.handle}
513
- </div>
514
- </div>
515
- <div
516
- className="size-2 rounded-full"
517
- style={{
518
- backgroundColor: relationshipColor(
519
- feature.properties.relationship,
520
- ),
521
- }}
522
- />
523
- </div>
524
- ))}
525
- </div>
526
- </div>
527
- );
528
- }
529
-
530
- function ProfileRow({ feature }: { feature: MapFeature }) {
531
- return (
532
- <a
533
- className="flex min-w-0 gap-3 border-b border-[var(--line)] px-4 py-3 transition-colors hover:bg-[var(--bg-hover)]"
534
- href={`/profiles/${encodeURIComponent(feature.properties.handle)}`}
535
- >
536
- <Avatar feature={feature} size={40} className="ring-[var(--bg)]" />
537
- <div className="min-w-0 flex-1">
538
- <div className="flex min-w-0 items-center gap-1.5">
539
- <span className="truncate font-bold text-[var(--ink)]">
540
- {feature.properties.name}
541
- </span>
542
- <span className="truncate text-[var(--ink-soft)]">
543
- @{feature.properties.handle}
544
- </span>
545
- </div>
546
- <div className="truncate text-[13px] text-[var(--ink-soft)]">
547
- {feature.properties.location}
548
- {feature.properties.resolvedLocation
549
- ? ` -> ${feature.properties.resolvedLocation}`
550
- : ""}
551
- </div>
552
- <div className="mt-1 flex flex-wrap gap-2 text-[12px] text-[var(--ink-soft)]">
553
- <span>{formatRelationship(feature.properties.relationship)}</span>
554
- <span>
555
- {formatNumber(feature.properties.followersCount)} followers
556
- </span>
557
- </div>
558
- </div>
559
- </a>
560
- );
561
- }
562
-
563
- function VisibleProfilesPanel({
564
- features,
565
- search,
566
- onSearchChange,
567
- totalVisible,
568
- zoom,
569
- }: {
570
- features: MapFeature[];
571
- search: string;
572
- onSearchChange: (value: string) => void;
573
- totalVisible: number;
574
- zoom: number;
575
- }) {
576
- return (
577
- <aside className="flex min-h-[420px] min-w-0 flex-col border-t border-[var(--line)] bg-[var(--bg)] min-[1180px]:h-full min-[1180px]:border-t-0 min-[1180px]:border-l">
578
- <header className="sticky top-0 z-10 border-b border-[var(--line)] bg-[color:color-mix(in_srgb,var(--bg)_88%,transparent)] px-4 py-3 backdrop-blur">
579
- <div className="flex items-start justify-between gap-3">
580
- <div className="min-w-0">
581
- <h2 className="truncate text-[16px] font-bold text-[var(--ink)]">
582
- Who's In View
583
- </h2>
584
- <p className="truncate text-[13px] text-[var(--ink-soft)]">
585
- {formatNumber(totalVisible)} in this map view · zoom{" "}
586
- {zoom.toFixed(1)}
587
- </p>
588
- </div>
589
- <div className="rounded-full border border-[var(--line)] px-2 py-1 text-[12px] font-semibold text-[var(--ink-soft)]">
590
- {formatNumber(features.length)}
591
- </div>
592
- </div>
593
- <label className={cx(searchFieldShellClass, "mt-3 h-10")}>
594
- <Search className={searchFieldIconClass} strokeWidth={2} />
595
- <input
596
- className={searchFieldInputClass}
597
- onChange={(event) => onSearchChange(event.target.value)}
598
- placeholder="Search visible people"
599
- value={search}
600
- />
601
- </label>
602
- </header>
603
- <div className="min-h-0 flex-1 overflow-y-auto">
604
- {features.length > 0 ? (
605
- features.map((feature) => (
606
- <ProfileRow key={feature.properties.profileId} feature={feature} />
607
- ))
608
- ) : (
609
- <div className={statusCopyClass}>
610
- {search.trim()
611
- ? "No visible profiles match that search."
612
- : "Pan or zoom the map to see profiles in this area."}
613
- </div>
614
- )}
615
- </div>
616
- </aside>
617
- );
618
- }
619
-
620
- function NetworkMapRoute() {
621
- const {
622
- type,
623
- setType,
624
- viewport,
625
- setViewport,
626
- visibleSearch,
627
- setVisibleSearch,
628
- data,
629
- loading,
630
- error,
631
- refresh,
632
- visibleFeatures,
633
- filteredVisibleFeatures,
634
- mapTypes,
635
- } = useNetworkMapController();
636
-
637
- return (
638
- <section className="flex min-h-screen flex-col min-[1180px]:h-screen min-[1180px]:min-h-0 min-[1180px]:overflow-hidden">
639
- <header className={pageHeaderClass}>
640
- <div className={pageHeaderRowClass}>
641
- <div>
642
- <h1 className={pageTitleClass}>Network Map</h1>
643
- <div className={pageSubtitleClass}>
644
- {data
645
- ? `${formatNumber(data.meta.locatedProfiles)} located · ${formatNumber(data.meta.meaningfulProfiles)} with usable locations`
646
- : "Loading network geography..."}
647
- </div>
648
- </div>
649
- <div className={pageHeaderActionsClass}>
650
- <button
651
- className={secondaryButtonClass}
652
- type="button"
653
- onClick={() => refresh()}
654
- disabled={loading}
655
- >
656
- <RefreshCw className={cx("size-4", loading && "animate-spin")} />
657
- Refresh
658
- </button>
659
- </div>
660
- </div>
661
- <div className="border-t border-[var(--line)] px-4 py-3">
662
- <div className={segmentedClass}>
663
- {mapTypes.map((item) => (
664
- <button
665
- key={item.value}
666
- type="button"
667
- className={cx(
668
- segmentClass,
669
- type === item.value && segmentActiveClass,
670
- )}
671
- onClick={() => setType(item.value)}
672
- >
673
- {item.label}
674
- </button>
675
- ))}
676
- </div>
677
- </div>
678
- </header>
679
-
680
- {error ? <div className={errorCopyClass}>{error}</div> : null}
681
- {data ? (
682
- <div className="grid min-h-[620px] flex-1 grid-cols-1 min-[1180px]:min-h-0 min-[1180px]:grid-cols-[minmax(0,1fr)_390px] min-[1180px]:overflow-hidden min-[1500px]:grid-cols-[minmax(0,1fr)_430px]">
683
- <div className="flex min-h-0 min-w-0 flex-col">
684
- <div className="grid sm:grid-cols-4">
685
- <StatTile
686
- icon={Users}
687
- label="Profiles"
688
- value={data.meta.totalProfiles}
689
- />
690
- <StatTile
691
- icon={MapPin}
692
- label="Locations"
693
- value={data.meta.meaningfulProfiles}
694
- />
695
- <StatTile
696
- icon={Globe2}
697
- label="Located"
698
- value={data.meta.locatedProfiles}
699
- />
700
- <StatTile
701
- icon={RefreshCw}
702
- label="Geocoded"
703
- value={data.meta.geocodedThisRun}
704
- />
705
- </div>
706
- {!data.meta.opencageConfigured && data.meta.missingGeocodes > 0 ? (
707
- <div className={statusCopyClass}>
708
- OpenCage key missing; showing cached and coordinate locations
709
- only.
710
- </div>
711
- ) : null}
712
- {!data.meta.mapboxTokenConfigured ? (
713
- <div className={statusCopyClass}>
714
- Mapbox token missing; showing the lightweight map.
715
- </div>
716
- ) : null}
717
- <MapboxPanel data={data} onViewportChange={setViewport} />
718
- </div>
719
- <VisibleProfilesPanel
720
- features={filteredVisibleFeatures}
721
- onSearchChange={setVisibleSearch}
722
- search={visibleSearch}
723
- totalVisible={visibleFeatures.length}
724
- zoom={viewport.zoom}
725
- />
726
- </div>
727
- ) : loading ? (
728
- <div className={statusCopyClass}>Loading map...</div>
729
- ) : null}
730
- </section>
731
- );
732
- }