ref0-git 0.0.0 → 0.3.0

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 (385) hide show
  1. package/app/apps/github/.dev.vars.example +6 -0
  2. package/app/apps/github/README.md +70 -0
  3. package/app/apps/github/THIRD_PARTY_NOTICES.md +214 -0
  4. package/app/apps/github/components.json +25 -0
  5. package/app/apps/github/generated/git-rest.ts +10444 -0
  6. package/app/apps/github/generated/routeTree.gen.ts +1242 -0
  7. package/app/apps/github/migrations/postgres/0001_auth.sql +46 -0
  8. package/app/apps/github/migrations/sql/0001_auth.sql +19 -0
  9. package/app/apps/github/migrations/sql/0002_passkeys.sql +9 -0
  10. package/app/apps/github/migrations/sql/0003_orgs.sql +22 -0
  11. package/app/apps/github/migrations/sql/0004_avatars.sql +6 -0
  12. package/app/apps/github/package.json +80 -0
  13. package/app/apps/github/src/branches/branch-list.tsx +385 -0
  14. package/app/apps/github/src/branches/branches.ts +55 -0
  15. package/app/apps/github/src/clients/allowed.ts +213 -0
  16. package/app/apps/github/src/clients/at-most.ts +17 -0
  17. package/app/apps/github/src/clients/avatars.ts +410 -0
  18. package/app/apps/github/src/clients/cached.ts +65 -0
  19. package/app/apps/github/src/clients/calls.ts +160 -0
  20. package/app/apps/github/src/clients/clients.ts +82 -0
  21. package/app/apps/github/src/clients/graphql.ts +50 -0
  22. package/app/apps/github/src/clients/host-answer.ts +28 -0
  23. package/app/apps/github/src/clients/host-calls.ts +382 -0
  24. package/app/apps/github/src/clients/icon-bytes.ts +203 -0
  25. package/app/apps/github/src/clients/proxy.ts +59 -0
  26. package/app/apps/github/src/clients/session-ended.ts +18 -0
  27. package/app/apps/github/src/clients/transfers.ts +212 -0
  28. package/app/apps/github/src/code/breadcrumbs.tsx +50 -0
  29. package/app/apps/github/src/code/code-page.tsx +147 -0
  30. package/app/apps/github/src/code/code-tree.tsx +338 -0
  31. package/app/apps/github/src/code/controls.tsx +230 -0
  32. package/app/apps/github/src/code/file-view.tsx +450 -0
  33. package/app/apps/github/src/code/files.ts +332 -0
  34. package/app/apps/github/src/code/folder-list.tsx +122 -0
  35. package/app/apps/github/src/code/go-to-file.tsx +131 -0
  36. package/app/apps/github/src/code/highlighted.tsx +58 -0
  37. package/app/apps/github/src/code/lines.ts +46 -0
  38. package/app/apps/github/src/code/load.ts +147 -0
  39. package/app/apps/github/src/code/markdown-files.ts +58 -0
  40. package/app/apps/github/src/code/places.ts +88 -0
  41. package/app/apps/github/src/code/ref-pages.ts +179 -0
  42. package/app/apps/github/src/code/ref-switcher.tsx +203 -0
  43. package/app/apps/github/src/code/refs.ts +142 -0
  44. package/app/apps/github/src/code/repo-home.tsx +240 -0
  45. package/app/apps/github/src/code/repo.ts +105 -0
  46. package/app/apps/github/src/code/saved-reads.ts +199 -0
  47. package/app/apps/github/src/code/saved.ts +110 -0
  48. package/app/apps/github/src/code/tree-fold.ts +186 -0
  49. package/app/apps/github/src/code/trees.ts +136 -0
  50. package/app/apps/github/src/components/avatar-picture.ts +53 -0
  51. package/app/apps/github/src/components/avatar-url.ts +16 -0
  52. package/app/apps/github/src/components/confirm-action.tsx +100 -0
  53. package/app/apps/github/src/components/count.tsx +24 -0
  54. package/app/apps/github/src/components/create-button.tsx +38 -0
  55. package/app/apps/github/src/components/file-icons/file-icons.css +225 -0
  56. package/app/apps/github/src/components/file-icons/file-icons.tsx +138 -0
  57. package/app/apps/github/src/components/filter.tsx +35 -0
  58. package/app/apps/github/src/components/hotkeys/hotkeys.tsx +255 -0
  59. package/app/apps/github/src/components/item-list.tsx +65 -0
  60. package/app/apps/github/src/components/language-dot.tsx +29 -0
  61. package/app/apps/github/src/components/list-toolbar.tsx +82 -0
  62. package/app/apps/github/src/components/markdown/editor.tsx +57 -0
  63. package/app/apps/github/src/components/markdown/markdown.css +177 -0
  64. package/app/apps/github/src/components/markdown/markdown.tsx +82 -0
  65. package/app/apps/github/src/components/owner-card.tsx +196 -0
  66. package/app/apps/github/src/components/pull-status.tsx +34 -0
  67. package/app/apps/github/src/components/recent.ts +41 -0
  68. package/app/apps/github/src/components/relative-time.tsx +78 -0
  69. package/app/apps/github/src/components/repos/icon-hashes.ts +91 -0
  70. package/app/apps/github/src/components/repos/new-repo-form.tsx +196 -0
  71. package/app/apps/github/src/components/repos/repo-icon.tsx +47 -0
  72. package/app/apps/github/src/components/repos/repo-list.tsx +528 -0
  73. package/app/apps/github/src/components/repos/your-repos.tsx +124 -0
  74. package/app/apps/github/src/components/review-state.tsx +75 -0
  75. package/app/apps/github/src/components/route-dialog.tsx +137 -0
  76. package/app/apps/github/src/components/save-button.tsx +58 -0
  77. package/app/apps/github/src/components/shell/app-shell.tsx +164 -0
  78. package/app/apps/github/src/components/shell/create-org-dialog.tsx +118 -0
  79. package/app/apps/github/src/components/shell/create-row.tsx +49 -0
  80. package/app/apps/github/src/components/shell/link-menu.tsx +94 -0
  81. package/app/apps/github/src/components/shell/nav-user.tsx +97 -0
  82. package/app/apps/github/src/components/shell/owner-repos.tsx +247 -0
  83. package/app/apps/github/src/components/shell/owner-switcher.tsx +104 -0
  84. package/app/apps/github/src/components/shell/repo-switcher.tsx +179 -0
  85. package/app/apps/github/src/components/shell/sections.ts +31 -0
  86. package/app/apps/github/src/components/shell/submenu-chevron.ts +147 -0
  87. package/app/apps/github/src/components/signin/device-card.tsx +139 -0
  88. package/app/apps/github/src/components/signin/login-form.tsx +88 -0
  89. package/app/apps/github/src/components/signin/signin-page.tsx +33 -0
  90. package/app/apps/github/src/components/signin/signup-form.tsx +106 -0
  91. package/app/apps/github/src/components/states/live-status.tsx +42 -0
  92. package/app/apps/github/src/components/states/states.tsx +126 -0
  93. package/app/apps/github/src/components/tab-indicator.tsx +143 -0
  94. package/app/apps/github/src/components/theme-choice.tsx +108 -0
  95. package/app/apps/github/src/components/theme-provider.tsx +126 -0
  96. package/app/apps/github/src/components/tones.ts +23 -0
  97. package/app/apps/github/src/components/ui/alert-dialog.tsx +187 -0
  98. package/app/apps/github/src/components/ui/alert.tsx +78 -0
  99. package/app/apps/github/src/components/ui/avatar.tsx +106 -0
  100. package/app/apps/github/src/components/ui/badge.tsx +51 -0
  101. package/app/apps/github/src/components/ui/breadcrumb.tsx +124 -0
  102. package/app/apps/github/src/components/ui/button-group.tsx +87 -0
  103. package/app/apps/github/src/components/ui/button.tsx +61 -0
  104. package/app/apps/github/src/components/ui/calendar.tsx +221 -0
  105. package/app/apps/github/src/components/ui/card.tsx +102 -0
  106. package/app/apps/github/src/components/ui/checkbox.tsx +26 -0
  107. package/app/apps/github/src/components/ui/collapsible.tsx +19 -0
  108. package/app/apps/github/src/components/ui/combobox.tsx +304 -0
  109. package/app/apps/github/src/components/ui/command.tsx +208 -0
  110. package/app/apps/github/src/components/ui/dialog.tsx +156 -0
  111. package/app/apps/github/src/components/ui/dropdown-menu.tsx +290 -0
  112. package/app/apps/github/src/components/ui/empty.tsx +100 -0
  113. package/app/apps/github/src/components/ui/field.tsx +236 -0
  114. package/app/apps/github/src/components/ui/hover-card.tsx +48 -0
  115. package/app/apps/github/src/components/ui/input-group.tsx +163 -0
  116. package/app/apps/github/src/components/ui/input.tsx +19 -0
  117. package/app/apps/github/src/components/ui/item.tsx +201 -0
  118. package/app/apps/github/src/components/ui/kbd.tsx +27 -0
  119. package/app/apps/github/src/components/ui/label.tsx +33 -0
  120. package/app/apps/github/src/components/ui/popover.tsx +87 -0
  121. package/app/apps/github/src/components/ui/radio-group.tsx +35 -0
  122. package/app/apps/github/src/components/ui/select.tsx +198 -0
  123. package/app/apps/github/src/components/ui/separator.tsx +22 -0
  124. package/app/apps/github/src/components/ui/sheet.tsx +138 -0
  125. package/app/apps/github/src/components/ui/sidebar.tsx +724 -0
  126. package/app/apps/github/src/components/ui/skeleton.tsx +13 -0
  127. package/app/apps/github/src/components/ui/sonner.tsx +47 -0
  128. package/app/apps/github/src/components/ui/styles.css +242 -0
  129. package/app/apps/github/src/components/ui/table.tsx +113 -0
  130. package/app/apps/github/src/components/ui/tabs.tsx +79 -0
  131. package/app/apps/github/src/components/ui/textarea.tsx +17 -0
  132. package/app/apps/github/src/components/ui/title.ts +6 -0
  133. package/app/apps/github/src/components/ui/toggle-group.tsx +89 -0
  134. package/app/apps/github/src/components/ui/toggle.tsx +42 -0
  135. package/app/apps/github/src/components/ui/tooltip.tsx +63 -0
  136. package/app/apps/github/src/components/user-avatar.tsx +145 -0
  137. package/app/apps/github/src/components/view-tabs.tsx +42 -0
  138. package/app/apps/github/src/context/context.ts +133 -0
  139. package/app/apps/github/src/diffs/blobs.ts +94 -0
  140. package/app/apps/github/src/diffs/diff-view.tsx +155 -0
  141. package/app/apps/github/src/diffs/files.ts +121 -0
  142. package/app/apps/github/src/diffs/hunks.tsx +454 -0
  143. package/app/apps/github/src/diffs/patch.ts +131 -0
  144. package/app/apps/github/src/diffs/rows.ts +137 -0
  145. package/app/apps/github/src/history/commit-diff.ts +54 -0
  146. package/app/apps/github/src/history/commit-list.tsx +207 -0
  147. package/app/apps/github/src/history/commit-page.tsx +147 -0
  148. package/app/apps/github/src/history/history.ts +129 -0
  149. package/app/apps/github/src/hooks/allowed.ts +31 -0
  150. package/app/apps/github/src/hooks/answers.ts +65 -0
  151. package/app/apps/github/src/hooks/avatars.ts +54 -0
  152. package/app/apps/github/src/hooks/draft.ts +38 -0
  153. package/app/apps/github/src/hooks/open-counts.ts +127 -0
  154. package/app/apps/github/src/hooks/profiles.ts +120 -0
  155. package/app/apps/github/src/hooks/repos.ts +440 -0
  156. package/app/apps/github/src/hooks/use-mobile.ts +19 -0
  157. package/app/apps/github/src/hooks/viewer.ts +39 -0
  158. package/app/apps/github/src/inbox/count.ts +70 -0
  159. package/app/apps/github/src/inbox/inbox-item.tsx +66 -0
  160. package/app/apps/github/src/inbox/inbox-page.tsx +572 -0
  161. package/app/apps/github/src/inbox/marks.ts +130 -0
  162. package/app/apps/github/src/inbox/release-tags.ts +65 -0
  163. package/app/apps/github/src/inbox/search.ts +97 -0
  164. package/app/apps/github/src/inbox/subjects.ts +184 -0
  165. package/app/apps/github/src/inbox/subscription-controls.tsx +184 -0
  166. package/app/apps/github/src/inbox/subscriptions.ts +189 -0
  167. package/app/apps/github/src/inbox/threads.ts +198 -0
  168. package/app/apps/github/src/issues/changes.ts +332 -0
  169. package/app/apps/github/src/issues/counts.ts +62 -0
  170. package/app/apps/github/src/issues/issue-list.tsx +682 -0
  171. package/app/apps/github/src/issues/issue-page.tsx +533 -0
  172. package/app/apps/github/src/issues/issues.ts +566 -0
  173. package/app/apps/github/src/issues/label-dialog.tsx +310 -0
  174. package/app/apps/github/src/issues/labels-page.tsx +119 -0
  175. package/app/apps/github/src/issues/new-issue.tsx +79 -0
  176. package/app/apps/github/src/issues/parts.tsx +71 -0
  177. package/app/apps/github/src/issues/picker.tsx +298 -0
  178. package/app/apps/github/src/issues/search.ts +238 -0
  179. package/app/apps/github/src/issues/sidebar.tsx +236 -0
  180. package/app/apps/github/src/lib/cn.ts +8 -0
  181. package/app/apps/github/src/lib/highlighting.ts +13 -0
  182. package/app/apps/github/src/live/follow.ts +129 -0
  183. package/app/apps/github/src/live/sse.ts +74 -0
  184. package/app/apps/github/src/live/use-follow.ts +37 -0
  185. package/app/apps/github/src/markdown/README.md +53 -0
  186. package/app/apps/github/src/markdown/allowed-html.ts +69 -0
  187. package/app/apps/github/src/markdown/context.ts +206 -0
  188. package/app/apps/github/src/markdown/images.ts +81 -0
  189. package/app/apps/github/src/markdown/lookup.ts +127 -0
  190. package/app/apps/github/src/markdown/patches.ts +299 -0
  191. package/app/apps/github/src/markdown/query.ts +25 -0
  192. package/app/apps/github/src/markdown/references.ts +158 -0
  193. package/app/apps/github/src/markdown/render.ts +103 -0
  194. package/app/apps/github/src/names/owners.ts +51 -0
  195. package/app/apps/github/src/names/repos.ts +24 -0
  196. package/app/apps/github/src/palette/palette.tsx +562 -0
  197. package/app/apps/github/src/palette/recent.ts +116 -0
  198. package/app/apps/github/src/palette/rows.tsx +487 -0
  199. package/app/apps/github/src/palette/server.ts +107 -0
  200. package/app/apps/github/src/palette/targets.ts +306 -0
  201. package/app/apps/github/src/policy.ts +606 -0
  202. package/app/apps/github/src/private-repos.ts +47 -0
  203. package/app/apps/github/src/pulls/compare-page.tsx +342 -0
  204. package/app/apps/github/src/pulls/files-tab.tsx +776 -0
  205. package/app/apps/github/src/pulls/live.ts +124 -0
  206. package/app/apps/github/src/pulls/merge-box.tsx +367 -0
  207. package/app/apps/github/src/pulls/merge-button.ts +86 -0
  208. package/app/apps/github/src/pulls/pull-list.tsx +235 -0
  209. package/app/apps/github/src/pulls/pull-page.tsx +474 -0
  210. package/app/apps/github/src/pulls/pull.ts +468 -0
  211. package/app/apps/github/src/pulls/pulls.ts +318 -0
  212. package/app/apps/github/src/pulls/review.ts +350 -0
  213. package/app/apps/github/src/pulls/search.ts +130 -0
  214. package/app/apps/github/src/queue/queue-page.tsx +405 -0
  215. package/app/apps/github/src/queue/queue.ts +231 -0
  216. package/app/apps/github/src/releases/latest-release.tsx +55 -0
  217. package/app/apps/github/src/releases/overview.tsx +30 -0
  218. package/app/apps/github/src/releases/release-form.tsx +353 -0
  219. package/app/apps/github/src/releases/release-list.tsx +173 -0
  220. package/app/apps/github/src/releases/release-view.tsx +183 -0
  221. package/app/apps/github/src/releases/releases.ts +308 -0
  222. package/app/apps/github/src/releases/tag-list.tsx +134 -0
  223. package/app/apps/github/src/router.tsx +46 -0
  224. package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +33 -0
  225. package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +28 -0
  226. package/app/apps/github/src/routes/$owner/$repo/_code.tsx +11 -0
  227. package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +19 -0
  228. package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +19 -0
  229. package/app/apps/github/src/routes/$owner/$repo/_releases.tsx +23 -0
  230. package/app/apps/github/src/routes/$owner/$repo/branches.tsx +39 -0
  231. package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +34 -0
  232. package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +42 -0
  233. package/app/apps/github/src/routes/$owner/$repo/compare/$.tsx +19 -0
  234. package/app/apps/github/src/routes/$owner/$repo/index.tsx +24 -0
  235. package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +50 -0
  236. package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +53 -0
  237. package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +43 -0
  238. package/app/apps/github/src/routes/$owner/$repo/labels.tsx +22 -0
  239. package/app/apps/github/src/routes/$owner/$repo/pull/$number/checks.tsx +15 -0
  240. package/app/apps/github/src/routes/$owner/$repo/pull/$number/commits.tsx +15 -0
  241. package/app/apps/github/src/routes/$owner/$repo/pull/$number/files.tsx +15 -0
  242. package/app/apps/github/src/routes/$owner/$repo/pull/$number/index.tsx +19 -0
  243. package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +52 -0
  244. package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +48 -0
  245. package/app/apps/github/src/routes/$owner/$repo/queue.tsx +22 -0
  246. package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +58 -0
  247. package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +40 -0
  248. package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +35 -0
  249. package/app/apps/github/src/routes/$owner/$repo/route.tsx +102 -0
  250. package/app/apps/github/src/routes/$owner/$repo/settings/access.tsx +9 -0
  251. package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +16 -0
  252. package/app/apps/github/src/routes/$owner/$repo/settings/hooks/new.tsx +25 -0
  253. package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +17 -0
  254. package/app/apps/github/src/routes/$owner/$repo/settings/route.tsx +28 -0
  255. package/app/apps/github/src/routes/$owner/$repo/settings/rules.tsx +12 -0
  256. package/app/apps/github/src/routes/$owner/$repo/tokens.tsx +16 -0
  257. package/app/apps/github/src/routes/$owner/index.tsx +45 -0
  258. package/app/apps/github/src/routes/-nav.tsx +293 -0
  259. package/app/apps/github/src/routes/-root-testing.ts +107 -0
  260. package/app/apps/github/src/routes/__root.tsx +225 -0
  261. package/app/apps/github/src/routes/api.auth.$.ts +18 -0
  262. package/app/apps/github/src/routes/downloads/$owner/$repo/$asset.tsx +10 -0
  263. package/app/apps/github/src/routes/file-icons[.]svg.ts +21 -0
  264. package/app/apps/github/src/routes/icons/$owner/$repo.tsx +14 -0
  265. package/app/apps/github/src/routes/icons/$owner/index.tsx +14 -0
  266. package/app/apps/github/src/routes/icons/index.tsx +12 -0
  267. package/app/apps/github/src/routes/index.tsx +48 -0
  268. package/app/apps/github/src/routes/login.tsx +24 -0
  269. package/app/apps/github/src/routes/login_.code.tsx +31 -0
  270. package/app/apps/github/src/routes/new.tsx +91 -0
  271. package/app/apps/github/src/routes/notifications.tsx +20 -0
  272. package/app/apps/github/src/routes/orgs/$owner/issues.tsx +8 -0
  273. package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +8 -0
  274. package/app/apps/github/src/routes/orgs/$owner/releases.tsx +8 -0
  275. package/app/apps/github/src/routes/orgs/$owner/route.tsx +25 -0
  276. package/app/apps/github/src/routes/orgs/$owner/settings.tsx +30 -0
  277. package/app/apps/github/src/routes/orgs/$owner/tokens.tsx +15 -0
  278. package/app/apps/github/src/routes/settings.tsx +54 -0
  279. package/app/apps/github/src/routes/signup.tsx +24 -0
  280. package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +10 -0
  281. package/app/apps/github/src/seed/acme.ts +498 -0
  282. package/app/apps/github/src/seed/licenses.ts +114 -0
  283. package/app/apps/github/src/seed/seed.ts +528 -0
  284. package/app/apps/github/src/server.ts +97 -0
  285. package/app/apps/github/src/settings/account-avatar.tsx +43 -0
  286. package/app/apps/github/src/settings/avatar-section.tsx +140 -0
  287. package/app/apps/github/src/settings/avatar.ts +58 -0
  288. package/app/apps/github/src/settings/general-settings.tsx +439 -0
  289. package/app/apps/github/src/settings/general.ts +73 -0
  290. package/app/apps/github/src/settings/hook-form.tsx +195 -0
  291. package/app/apps/github/src/settings/hook-list.tsx +166 -0
  292. package/app/apps/github/src/settings/hooks.ts +87 -0
  293. package/app/apps/github/src/settings/org-settings.tsx +228 -0
  294. package/app/apps/github/src/settings/orgs.ts +116 -0
  295. package/app/apps/github/src/settings/rule-list.tsx +72 -0
  296. package/app/apps/github/src/settings/rules.ts +27 -0
  297. package/app/apps/github/src/settings/settings-layout.tsx +114 -0
  298. package/app/apps/github/src/signin/approval.ts +186 -0
  299. package/app/apps/github/src/signin/auth-client.ts +127 -0
  300. package/app/apps/github/src/signin/auth.ts +753 -0
  301. package/app/apps/github/src/signin/avatars.ts +126 -0
  302. package/app/apps/github/src/signin/client-ip.ts +39 -0
  303. package/app/apps/github/src/signin/credentials.ts +26 -0
  304. package/app/apps/github/src/signin/device-code.ts +95 -0
  305. package/app/apps/github/src/signin/device-prompt.ts +125 -0
  306. package/app/apps/github/src/signin/errors.ts +135 -0
  307. package/app/apps/github/src/signin/host-session.ts +68 -0
  308. package/app/apps/github/src/signin/orgs.ts +283 -0
  309. package/app/apps/github/src/signin/owner-names.ts +183 -0
  310. package/app/apps/github/src/signin/person-lock.ts +104 -0
  311. package/app/apps/github/src/signin/seal.ts +88 -0
  312. package/app/apps/github/src/signin/seed-people.ts +92 -0
  313. package/app/apps/github/src/signin/session.ts +48 -0
  314. package/app/apps/github/src/signin/unborn.ts +110 -0
  315. package/app/apps/github/src/signin/viewer-orgs.ts +47 -0
  316. package/app/apps/github/src/signin/viewer.ts +74 -0
  317. package/app/apps/github/src/signin/with-headers.ts +14 -0
  318. package/app/apps/github/src/tokens/tokens-page.tsx +529 -0
  319. package/app/apps/github/src/tokens/tokens.ts +54 -0
  320. package/app/apps/github/tsconfig.json +25 -0
  321. package/app/apps/github/tsconfig.worker.json +24 -0
  322. package/app/apps/github/vite.config.ts +21 -0
  323. package/app/pnpm-workspace.yaml +216 -0
  324. package/app/tsconfig.base.json +127 -0
  325. package/dist/LICENSE +202 -0
  326. package/dist/cli/child.mjs +42 -0
  327. package/dist/cli/commands.mjs +23 -0
  328. package/dist/cli/credentials.mjs +84 -0
  329. package/dist/cli/documents.mjs +214 -0
  330. package/dist/cli/events.mjs +55 -0
  331. package/dist/cli/failure.mjs +105 -0
  332. package/dist/cli/folders.mjs +32 -0
  333. package/dist/cli/git-remote-ref0.d.mts +1 -0
  334. package/dist/cli/git-remote-ref0.mjs +29 -0
  335. package/dist/cli/git.mjs +69 -0
  336. package/dist/cli/helpers.mjs +184 -0
  337. package/dist/cli/hosts.mjs +127 -0
  338. package/dist/cli/node.mjs +15 -0
  339. package/dist/cli/output.mjs +135 -0
  340. package/dist/cli/prompt.mjs +35 -0
  341. package/dist/cli/queue.mjs +215 -0
  342. package/dist/cli/ref0-git.d.mts +1 -0
  343. package/dist/cli/ref0-git.mjs +144 -0
  344. package/dist/cli/repos.mjs +162 -0
  345. package/dist/cli/resources.mjs +131 -0
  346. package/dist/cli/run-end.mjs +57 -0
  347. package/dist/cli/runtime.mjs +50 -0
  348. package/dist/cli/setup.mjs +1410 -0
  349. package/dist/cli/sign-in.mjs +162 -0
  350. package/dist/cli/sign-ins.mjs +136 -0
  351. package/dist/cli/sqlite.mjs +28 -0
  352. package/dist/cli/tokens.mjs +141 -0
  353. package/dist/cli/vendor.mjs +123 -0
  354. package/dist/init/app.mjs +231 -0
  355. package/dist/init/astro.mjs +49 -0
  356. package/dist/init/choices.mjs +497 -0
  357. package/dist/init/cloudflare.mjs +324 -0
  358. package/dist/init/create.mjs +151 -0
  359. package/dist/init/detect.mjs +297 -0
  360. package/dist/init/files.mjs +80 -0
  361. package/dist/init/frameworks.mjs +248 -0
  362. package/dist/init/git-module.mjs +49 -0
  363. package/dist/init/github-routes.mjs +66 -0
  364. package/dist/init/jsonc.mjs +143 -0
  365. package/dist/init/metadata.mjs +48 -0
  366. package/dist/init/mounts.mjs +109 -0
  367. package/dist/init/next.mjs +203 -0
  368. package/dist/init/node-app.mjs +189 -0
  369. package/dist/init/node.mjs +460 -0
  370. package/dist/init/nuxt.mjs +115 -0
  371. package/dist/init/output.mjs +21 -0
  372. package/dist/init/plan.mjs +82 -0
  373. package/dist/init/range-major.mjs +257 -0
  374. package/dist/init/react-router.mjs +59 -0
  375. package/dist/init/routes.mjs +148 -0
  376. package/dist/init/shell.mjs +4 -0
  377. package/dist/init/stores.mjs +51 -0
  378. package/dist/init/sveltekit.mjs +139 -0
  379. package/dist/init/template.mjs +142 -0
  380. package/dist/init/templates.mjs +343 -0
  381. package/dist/init/vercel.mjs +384 -0
  382. package/dist/init/versions.mjs +32 -0
  383. package/dist/init/workspace.mjs +20 -0
  384. package/package.json +48 -6
  385. package/README.md +0 -5
@@ -0,0 +1,137 @@
1
+ import type { FileDiffMetadata, SelectedLineRange, SelectionSide } from '@pierre/diffs';
2
+
3
+ /** A row of a unified diff, as a pick names it: a line on the old file's side, or the new's. */
4
+ export interface Row {
5
+ readonly side: SelectionSide;
6
+ readonly line: number;
7
+ }
8
+
9
+ const run = (side: SelectionSide, from: number, count: number): Row[] =>
10
+ Array.from({ length: count }, (_, at) => ({ side, line: from + at }));
11
+
12
+ /**
13
+ * `diff`'s rows in the order its unified view draws them: in each change, the removed lines and
14
+ * then the added. An unchanged line is picked on the new side, as the gutter picks it.
15
+ */
16
+ export const rowsOf = (diff: FileDiffMetadata): readonly Row[] =>
17
+ diff.hunks.flatMap((hunk) => {
18
+ let removed = hunk.deletionStart;
19
+ let added = hunk.additionStart;
20
+
21
+ return hunk.hunkContent.flatMap((content) => {
22
+ if (content.type === 'context') {
23
+ const rows = run('additions', added, content.lines);
24
+ removed += content.lines;
25
+ added += content.lines;
26
+
27
+ return rows;
28
+ }
29
+
30
+ const rows = [
31
+ ...run('deletions', removed, content.deletions),
32
+ ...run('additions', added, content.additions),
33
+ ];
34
+ removed += content.deletions;
35
+ added += content.additions;
36
+
37
+ return rows;
38
+ });
39
+ });
40
+
41
+ /** A drawn row's side: a removed line is the old file's, and any other the new's, as picked. */
42
+ const sideDrawn = (row: Element): SelectionSide =>
43
+ row.getAttribute('data-line-type') === 'change-deletion' ? 'deletions' : 'additions';
44
+
45
+ /** Each row `@pierre/diffs` draws in `root`, a diff's shadow root, in the order it draws them. */
46
+ const rowsIn = (root: ParentNode) =>
47
+ root.querySelectorAll('[data-content] > [data-line][data-line-type]');
48
+
49
+ /**
50
+ * The rows `root` draws, in order: the hunks' and any context expanded between them, as far as
51
+ * the window has drawn them.
52
+ */
53
+ export const drawnRows = (root: ParentNode): readonly Row[] =>
54
+ [...rowsIn(root)].map((row) => ({
55
+ side: sideDrawn(row),
56
+ line: Number(row.getAttribute('data-line')),
57
+ }));
58
+
59
+ /** The element `root` draws `line` on `side` in, when the window has drawn it. */
60
+ export const rowDrawn = (root: ParentNode, line: number, side: SelectionSide) =>
61
+ [...rowsIn(root)].find(
62
+ (row) => row.getAttribute('data-line') === String(line) && sideDrawn(row) === side,
63
+ );
64
+
65
+ const sideOf = (range: SelectedLineRange, end: boolean) =>
66
+ (end ? range.endSide : undefined) ?? range.side ?? 'additions';
67
+
68
+ const indexOf = (rows: readonly Row[], line: number, side: SelectionSide) =>
69
+ rows.findIndex((row) => row.line === line && row.side === side);
70
+
71
+ /**
72
+ * The rows a key moves over, or a pick is ordered in: those `drawn`, when they hold each of
73
+ * `needed`, so context expanded between hunks counts; else the hunks' own.
74
+ */
75
+ export const rowsHolding = (drawn: readonly Row[], hunks: readonly Row[], needed: readonly Row[]) =>
76
+ needed.length > 0 && needed.every((row) => indexOf(drawn, row.line, row.side) !== -1)
77
+ ? drawn
78
+ : hunks;
79
+
80
+ /** Where `range` starts and where it ends, the end being the row a key moves and shows. */
81
+ export const endsOf = (range: SelectedLineRange) => ({
82
+ start: { line: range.start, side: sideOf(range, false) },
83
+ end: { line: range.end, side: sideOf(range, true) },
84
+ });
85
+
86
+ /**
87
+ * The selection after a key moves its end `by` rows, from `selected`: one row, or with `extend`
88
+ * a range from where it started. Nothing selected starts at the first row.
89
+ */
90
+ export const moved = (
91
+ rows: readonly Row[],
92
+ selected: SelectedLineRange | null,
93
+ by: number,
94
+ extend: boolean,
95
+ ): SelectedLineRange | null => {
96
+ const at = selected === null ? -1 : indexOf(rows, selected.end, sideOf(selected, true));
97
+ const next = rows[at === -1 ? 0 : Math.min(Math.max(at + by, 0), rows.length - 1)];
98
+ if (next === undefined) return null;
99
+
100
+ if (!extend || selected === null) {
101
+ return { start: next.line, side: next.side, end: next.line, endSide: next.side };
102
+ }
103
+
104
+ return {
105
+ start: selected.start,
106
+ side: sideOf(selected, false),
107
+ end: next.line,
108
+ endSide: next.side,
109
+ };
110
+ };
111
+
112
+ /**
113
+ * `range` from its upper row to its lower, as the unified view draws them, whichever way it was
114
+ * picked: a range dragged upward from an added line to a removed one ends on the added.
115
+ */
116
+ export const inOrder = (rows: readonly Row[], range: SelectedLineRange): SelectedLineRange => {
117
+ const { start, end } = endsOf(range);
118
+ const from = indexOf(rows, start.line, start.side);
119
+ const to = indexOf(rows, end.line, end.side);
120
+ if (from === -1 || to === -1 || from <= to) return range;
121
+
122
+ return { start: end.line, side: end.side, end: start.line, endSide: start.side };
123
+ };
124
+
125
+ /** How a row is read aloud: the old file's line, or the new's. */
126
+ export const rowSaid = (line: number, side: SelectionSide) =>
127
+ `${side === 'deletions' ? 'old' : 'new'} line ${line}`;
128
+
129
+ /** What `range` picks, read aloud, or nothing. */
130
+ export const rangeSaid = (range: SelectedLineRange | null) => {
131
+ if (range === null) return '';
132
+
133
+ const start = rowSaid(range.start, sideOf(range, false));
134
+ const end = rowSaid(range.end, sideOf(range, true));
135
+
136
+ return start === end ? start : `${start} to ${end}`;
137
+ };
@@ -0,0 +1,54 @@
1
+ import { queryOptions, type QueryClient } from '@tanstack/react-query';
2
+ import * as Schema from 'effect/Schema';
3
+
4
+ import { github } from '../clients/clients.ts';
5
+ import type { RepoPlace } from '../code/places.ts';
6
+ import type { ChangedFile, FileList } from '../diffs/files.ts';
7
+
8
+ /**
9
+ * The most files GitHub's REST, and the drop-in, list for one commit, each with its patch. A
10
+ * commit that changed more lists these and no `stats`.
11
+ */
12
+ export const commitFilesMost = 300;
13
+
14
+ const isText = Schema.is(Schema.String);
15
+
16
+ /** A commit's changed files, and whether they're all of them. */
17
+ export interface CommitFiles {
18
+ readonly files: readonly ChangedFile[];
19
+ readonly whole: boolean;
20
+ }
21
+
22
+ /**
23
+ * A commit's changed files against its first parent, or against nothing for the first commit,
24
+ * in one call: the drop-in answers `stats` only when the list is whole.
25
+ */
26
+ export const commitFiles = (place: RepoPlace, sha: string) =>
27
+ queryOptions({
28
+ queryKey: ['commit-files', place.owner, place.repo, sha],
29
+ queryFn: async ({ signal }): Promise<CommitFiles> => {
30
+ const answer = await github.GET('/repos/{owner}/{repo}/commits/{ref}', {
31
+ params: { path: { ...place, ref: sha } },
32
+ signal,
33
+ });
34
+
35
+ // JSON, as asked: the types allow the diff's text other media types answer.
36
+ const commit = answer.data;
37
+
38
+ if (commit === undefined || isText(commit)) {
39
+ throw new Error(`The commit's changes didn't load (${answer.response.status})`);
40
+ }
41
+
42
+ return { files: commit.files ?? [], whole: commit.stats !== undefined };
43
+ },
44
+ staleTime: Infinity,
45
+ });
46
+
47
+ /** A commit's files as `DiffView` lists them: one page, from the call its page already made. */
48
+ export const commitFileList = (client: QueryClient, place: RepoPlace, sha: string): FileList => ({
49
+ key: ['commit-files', place.owner, place.repo, sha],
50
+ page: async () => ({
51
+ files: (await client.fetchQuery(commitFiles(place, sha))).files,
52
+ next: undefined,
53
+ }),
54
+ });
@@ -0,0 +1,207 @@
1
+ import { useQueryClient } from '@tanstack/react-query';
2
+ import { useRouter } from '@tanstack/react-router';
3
+ import { CodeIcon, GitCommitIcon } from 'lucide-react';
4
+
5
+ import { ItemList } from '../components/item-list.tsx';
6
+ import { RelativeTime } from '../components/relative-time.tsx';
7
+ import { Alert, AlertDescription } from '../components/ui/alert.tsx';
8
+ import { Button, buttonVariants } from '../components/ui/button.tsx';
9
+ import { ButtonGroup } from '../components/ui/button-group.tsx';
10
+ import { Card } from '../components/ui/card.tsx';
11
+ import { Empty, EmptyHeader, EmptyMedia, EmptyTitle } from '../components/ui/empty.tsx';
12
+ import {
13
+ Item,
14
+ ItemActions,
15
+ ItemContent,
16
+ ItemDescription,
17
+ ItemMedia,
18
+ ItemTitle,
19
+ } from '../components/ui/item.tsx';
20
+ import { Skeleton } from '../components/ui/skeleton.tsx';
21
+ import { Tooltip, TooltipContent, TooltipTrigger } from '../components/ui/tooltip.tsx';
22
+ import { OwnerCard } from '../components/owner-card.tsx';
23
+ import { UserAvatar } from '../components/user-avatar.tsx';
24
+ import { CopyButton, day, Go } from '../code/controls.tsx';
25
+ import { commitHref, treeHref, type At } from '../code/places.ts';
26
+ import type { CommitRow } from '../code/refs.ts';
27
+ import { history, useHistory } from './history.ts';
28
+
29
+ /** The first line of a commit's message: its title. */
30
+ export const titleOf = (message: string) => message.split('\n', 1)[0] ?? '';
31
+
32
+ /** Rows in their order, under the day each was written: GitHub's "Commits on Nov 20, 2026". */
33
+ const byDay = (rows: readonly CommitRow[]) => {
34
+ const days: { day: string; rows: CommitRow[] }[] = [];
35
+
36
+ for (const row of rows) {
37
+ const label = row.date === undefined ? 'Undated' : day.format(new Date(row.date));
38
+ const last = days.at(-1);
39
+ if (last?.day === label) last.rows.push(row);
40
+ else days.push({ day: label, rows: [row] });
41
+ }
42
+
43
+ return days;
44
+ };
45
+
46
+ function Row({ at, row }: { readonly at: At; readonly row: CommitRow }) {
47
+ const who = row.login ?? row.author;
48
+ const short = row.sha.slice(0, 7);
49
+ const browse = `Browse the repository at ${short}`;
50
+
51
+ return (
52
+ <Item role="listitem" className="flex-nowrap max-sm:flex-wrap">
53
+ <ItemMedia>
54
+ <UserAvatar login={who} size="sm" account="user" />
55
+ </ItemMedia>
56
+ <ItemContent className="min-w-0">
57
+ <ItemTitle className="block w-full truncate">
58
+ <Go href={commitHref(at, row.sha)} className="hover:underline">
59
+ {titleOf(row.message)}
60
+ </Go>
61
+ </ItemTitle>
62
+ <ItemDescription>
63
+ {row.login === undefined ? who : <OwnerCard login={row.login}>{who}</OwnerCard>} committed
64
+ {row.parents.length > 1 && ' a merge'}
65
+ {row.date !== undefined && (
66
+ <>
67
+ {' '}
68
+ <RelativeTime at={row.date} />
69
+ </>
70
+ )}
71
+ </ItemDescription>
72
+ </ItemContent>
73
+ <ItemActions className="max-sm:ml-9 max-sm:basis-full">
74
+ <ButtonGroup>
75
+ <Go
76
+ data-slot="button"
77
+ href={commitHref(at, row.sha)}
78
+ className={`${buttonVariants({ variant: 'outline', size: 'sm' })} font-mono`}
79
+ >
80
+ {short}
81
+ </Go>
82
+ <CopyButton text={row.sha} label="Copy full commit ID" />
83
+ </ButtonGroup>
84
+ <Tooltip>
85
+ <TooltipTrigger
86
+ render={
87
+ <Go
88
+ href={treeHref(at, row.sha, '')}
89
+ aria-label={browse}
90
+ className={buttonVariants({ variant: 'ghost', size: 'icon-sm' })}
91
+ />
92
+ }
93
+ >
94
+ <CodeIcon />
95
+ </TooltipTrigger>
96
+ <TooltipContent>{browse}</TooltipContent>
97
+ </Tooltip>
98
+ </ItemActions>
99
+ </Item>
100
+ );
101
+ }
102
+
103
+ /** Commits under the day each was written, in the order given, as GitHub lists them. */
104
+ export function CommitDays({ at, rows }: { readonly at: At; readonly rows: readonly CommitRow[] }) {
105
+ return byDay(rows).map((group) => (
106
+ <section key={group.day} aria-label={`Commits on ${group.day}`} className="flex flex-col gap-2">
107
+ <h2 className="flex items-center gap-2 text-meta text-muted-foreground">
108
+ <GitCommitIcon aria-hidden className="size-4" />
109
+ Commits on {group.day}
110
+ </h2>
111
+ <Card className="gap-0 py-0">
112
+ <ItemList
113
+ rows={group.rows}
114
+ keyOf={(row) => row.sha}
115
+ row={(row) => <Row at={at} row={row} />}
116
+ />
117
+ </Card>
118
+ </section>
119
+ ));
120
+ }
121
+
122
+ /**
123
+ * Where the next page would be once the repository has gone from under the reader: a later page
124
+ * reads the commits its first page named however the refs move, so only the repository going, or
125
+ * the reader losing read, ends it. The commits shown stay, and Reload reads the history again from
126
+ * its first page, or finds there's nothing there to read.
127
+ */
128
+ function Changed({ at }: { readonly at: At }) {
129
+ const client = useQueryClient();
130
+ const router = useRouter();
131
+ const reload = async () => {
132
+ await client.resetQueries({ queryKey: history(at, at.ref, at.path).queryKey });
133
+ await router.invalidate();
134
+ };
135
+
136
+ return (
137
+ <p className="flex flex-wrap items-center justify-center gap-1 text-meta text-muted-foreground">
138
+ <span>This repository changed while you were reading. Reload to see its history now</span>
139
+ <Button variant="link" size="xs" onClick={() => void reload()}>
140
+ Reload
141
+ </Button>
142
+ </p>
143
+ );
144
+ }
145
+
146
+ /**
147
+ * A ref's history, or a path's at it, a page at a time: the reader asks for the next, so a long
148
+ * history costs only the pages read.
149
+ */
150
+ export function CommitList({ at }: { readonly at: At }) {
151
+ const pages = useHistory(at, at.ref, at.path);
152
+ const rows = pages.data?.pages.flatMap((page) => page?.rows ?? []) ?? [];
153
+ const changed = pages.data?.pages.at(-1) === null;
154
+
155
+ if (pages.isPending) {
156
+ return (
157
+ <div className="flex flex-col gap-2">
158
+ {Array.from({ length: 6 }, (_, index) => (
159
+ <Skeleton key={index} className="h-12" />
160
+ ))}
161
+ </div>
162
+ );
163
+ }
164
+
165
+ if (pages.error !== null && rows.length === 0) {
166
+ return (
167
+ <Alert variant="destructive">
168
+ <AlertDescription>{pages.error.message}. Reload the page to try again.</AlertDescription>
169
+ </Alert>
170
+ );
171
+ }
172
+
173
+ if (rows.length === 0) {
174
+ return (
175
+ <Empty className="border">
176
+ <EmptyHeader>
177
+ <EmptyMedia variant="icon">
178
+ <GitCommitIcon />
179
+ </EmptyMedia>
180
+ <EmptyTitle>No commits {at.path === '' ? 'here' : 'touch this path'}</EmptyTitle>
181
+ </EmptyHeader>
182
+ </Empty>
183
+ );
184
+ }
185
+
186
+ return (
187
+ <div className="flex flex-col gap-4">
188
+ <CommitDays at={at} rows={rows} />
189
+ {pages.error !== null && (
190
+ <Alert variant="destructive">
191
+ <AlertDescription>{pages.error.message}</AlertDescription>
192
+ </Alert>
193
+ )}
194
+ {changed && <Changed at={at} />}
195
+ {pages.hasNextPage && (
196
+ <Button
197
+ variant="outline"
198
+ className="self-center"
199
+ disabled={pages.isFetchingNextPage}
200
+ onClick={() => void pages.fetchNextPage()}
201
+ >
202
+ {pages.isFetchingNextPage ? 'Loading…' : 'Older commits'}
203
+ </Button>
204
+ )}
205
+ </div>
206
+ );
207
+ }
@@ -0,0 +1,147 @@
1
+ import { useQuery, useQueryClient } from '@tanstack/react-query';
2
+ import { FolderCodeIcon, HistoryIcon } from 'lucide-react';
3
+
4
+ import { RelativeTime } from '../components/relative-time.tsx';
5
+ import { Alert, AlertDescription } from '../components/ui/alert.tsx';
6
+ import { buttonVariants } from '../components/ui/button.tsx';
7
+ import {
8
+ Card,
9
+ CardAction,
10
+ CardContent,
11
+ CardFooter,
12
+ CardHeader,
13
+ CardTitle,
14
+ } from '../components/ui/card.tsx';
15
+ import { Skeleton } from '../components/ui/skeleton.tsx';
16
+ import { UserAvatar } from '../components/user-avatar.tsx';
17
+ import { CopyButton, Go } from '../code/controls.tsx';
18
+ import { commitHref, commitsHref, treeHref, type RepoPlace } from '../code/places.ts';
19
+ import { DiffView } from '../diffs/diff-view.tsx';
20
+ import { commitFileList, commitFiles, commitFilesMost } from './commit-diff.ts';
21
+ import type { Commit } from './history.ts';
22
+ import { titleOf } from './commit-list.tsx';
23
+
24
+ /**
25
+ * A commit's diff against its first parent, in `DiffView`. The browser reads it once the page
26
+ * shows, so a commit's patches never ride in the server's HTML; until then, a box holds its place.
27
+ */
28
+ function CommitDiff({ place, commit }: { readonly place: RepoPlace; readonly commit: Commit }) {
29
+ const client = useQueryClient();
30
+ const changed = useQuery(commitFiles(place, commit.sha));
31
+
32
+ if (changed.isError) {
33
+ return (
34
+ <Alert variant="destructive">
35
+ <AlertDescription>{changed.error.message}</AlertDescription>
36
+ </Alert>
37
+ );
38
+ }
39
+
40
+ if (changed.data === undefined) return <Skeleton className="h-24" />;
41
+
42
+ const repo = `${place.owner}/${place.repo}`;
43
+
44
+ return (
45
+ <section aria-label="Changes" className="flex flex-col gap-2">
46
+ {!changed.data.whole && (
47
+ <p className="text-sm text-muted-foreground">
48
+ This commit changed more files than a page shows: here are the first{' '}
49
+ {commitFilesMost.toLocaleString('en')}. Clone the repository to see them all.
50
+ </p>
51
+ )}
52
+ <DiffView
53
+ list={commitFileList(client, place, commit.sha)}
54
+ revisions={{ repo, base: commit.parents[0] ?? commit.sha, head: commit.sha }}
55
+ />
56
+ </section>
57
+ );
58
+ }
59
+
60
+ /** One commit: its message, who wrote it and when, the commits it follows, and its diff. */
61
+ export function CommitPage({
62
+ place,
63
+ commit,
64
+ }: {
65
+ readonly place: RepoPlace;
66
+ readonly commit: Commit;
67
+ }) {
68
+ const body = commit.message.slice(titleOf(commit.message).length).trim();
69
+
70
+ return (
71
+ <article className="flex flex-col gap-4">
72
+ <Card>
73
+ <CardHeader className="max-sm:grid-cols-1">
74
+ <CardTitle>
75
+ <h1 className="text-base font-semibold break-words">{titleOf(commit.message)}</h1>
76
+ </CardTitle>
77
+ <CardAction className="flex gap-2 max-sm:col-start-1 max-sm:row-start-2 max-sm:justify-self-start">
78
+ <Go
79
+ href={treeHref(place, commit.sha, '')}
80
+ className={buttonVariants({ variant: 'outline', size: 'sm' })}
81
+ >
82
+ <FolderCodeIcon data-icon="inline-start" />
83
+ Browse files
84
+ </Go>
85
+ <Go
86
+ href={commitsHref(place, commit.sha)}
87
+ className={buttonVariants({ variant: 'ghost', size: 'sm' })}
88
+ >
89
+ <HistoryIcon data-icon="inline-start" />
90
+ History
91
+ </Go>
92
+ </CardAction>
93
+ </CardHeader>
94
+ {body !== '' && (
95
+ <CardContent>
96
+ <pre className="font-sans text-sm whitespace-pre-wrap text-muted-foreground">
97
+ {body}
98
+ </pre>
99
+ </CardContent>
100
+ )}
101
+ <CardFooter className="flex-wrap justify-between gap-x-6 gap-y-2 bg-muted/50">
102
+ <p className="flex flex-wrap items-center gap-x-1 gap-y-1">
103
+ <UserAvatar login={commit.author} size="sm" account="user" />
104
+ <span className="ml-1 font-medium">{commit.author}</span> authored{' '}
105
+ <RelativeTime at={commit.authored} />
106
+ {commit.committer !== commit.author && (
107
+ <>
108
+ {' · '}
109
+ <span className="font-medium">{commit.committer}</span> committed{' '}
110
+ <RelativeTime at={commit.committed} />
111
+ </>
112
+ )}
113
+ </p>
114
+ <dl className="flex flex-wrap items-center gap-x-4 gap-y-1">
115
+ <div className="flex flex-wrap items-center gap-2">
116
+ <dt className="text-muted-foreground">
117
+ {commit.parents.length === 1 ? 'Parent' : 'Parents'}
118
+ </dt>
119
+ <dd className="flex flex-wrap gap-2">
120
+ {commit.parents.length === 0 && (
121
+ <span className="text-muted-foreground">None: the first commit</span>
122
+ )}
123
+ {commit.parents.map((parent) => (
124
+ <Go
125
+ key={parent}
126
+ href={commitHref(place, parent)}
127
+ className="font-mono text-link hover:underline"
128
+ >
129
+ {parent.slice(0, 7)}
130
+ </Go>
131
+ ))}
132
+ </dd>
133
+ </div>
134
+ <div className="flex items-center gap-2">
135
+ <dt className="text-muted-foreground">Commit</dt>
136
+ <dd className="flex items-center gap-1">
137
+ <code className="font-mono">{commit.sha.slice(0, 7)}</code>
138
+ <CopyButton text={commit.sha} label="Copy full commit ID" />
139
+ </dd>
140
+ </div>
141
+ </dl>
142
+ </CardFooter>
143
+ </Card>
144
+ <CommitDiff place={place} commit={commit} />
145
+ </article>
146
+ );
147
+ }
@@ -0,0 +1,129 @@
1
+ import { queryOptions, useInfiniteQuery, type QueryClient } from '@tanstack/react-query';
2
+
3
+ import { revisionOf, type At, type Ref, type RepoPlace } from '../code/places.ts';
4
+ import { atOf, refFresh, rowOf, type CommitRow } from '../code/refs.ts';
5
+ import { repoAt } from '../code/repo.ts';
6
+ import { nextCursor } from '../hooks/repos.ts';
7
+ import { cached, cachedPages } from '../clients/cached.ts';
8
+ import { github } from '../clients/clients.ts';
9
+
10
+ /**
11
+ * A ref's history, or a path's at it, newest first: a page of commits at a time, each after the
12
+ * cursor the last page's `Link` names. A 50,000-commit history costs a call for each page read.
13
+ */
14
+
15
+ /** The commits a history page asks for, as GitHub's own pages show them. */
16
+ export const commitsPerPage = 35;
17
+
18
+ /** A page of history, and the cursor of the one after it. */
19
+ export interface HistoryPage {
20
+ readonly rows: readonly CommitRow[];
21
+ readonly next: string | undefined;
22
+ }
23
+
24
+ const firstPage: string | undefined = undefined;
25
+
26
+ /**
27
+ * One page of `ref`'s history, or of `path`'s at it, after `after`. `null` where the drop-in has
28
+ * none for `ref`, such as a tag on a tree or a blob, as GitHub's own page isn't found there.
29
+ */
30
+ export const historyPage = async (
31
+ place: RepoPlace,
32
+ ref: Ref,
33
+ path: string,
34
+ after: string | undefined,
35
+ ): Promise<HistoryPage | null> => {
36
+ // `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it, and
37
+ // the client leaves out what's `undefined`.
38
+ const paging = { sha: revisionOf(ref), per_page: commitsPerPage, after };
39
+ const query = path === '' ? { ...paging } : { ...paging, path };
40
+ const answer = await github.GET('/repos/{owner}/{repo}/commits', {
41
+ params: { path: place, query },
42
+ });
43
+ if (answer.response.status === 404) return null;
44
+
45
+ if (answer.data === undefined) {
46
+ throw new Error(`The history didn't load (${answer.response.status})`);
47
+ }
48
+
49
+ return { rows: answer.data.map(rowOf), next: nextCursor(answer.response.headers.get('link')) };
50
+ };
51
+
52
+ /** `ref`'s history, or `path`'s, a page at a time as the reader asks for more. */
53
+ export const history = (place: RepoPlace, ref: Ref, path: string) => ({
54
+ queryKey: ['history', place.owner, place.repo, ref.kind, ref.name, path] as const,
55
+ queryFn: ({ pageParam }: { readonly pageParam: string | undefined }) =>
56
+ historyPage(place, ref, path, pageParam),
57
+ initialPageParam: firstPage,
58
+ getNextPageParam: (last: HistoryPage | null) => last?.next,
59
+ staleTime: ref.kind === 'commit' ? Infinity : refFresh,
60
+ });
61
+
62
+ export const useHistory = (place: RepoPlace, ref: Ref, path: string) =>
63
+ useInfiniteQuery(history(place, ref, path));
64
+
65
+ /**
66
+ * What a history page loads: where its splat points, the repository's default branch for none,
67
+ * with its first page read. `undefined` where the URL names no repository or ref, or a ref with no
68
+ * history.
69
+ */
70
+ export const loadHistory = async (
71
+ client: QueryClient,
72
+ place: RepoPlace,
73
+ splat: string,
74
+ ): Promise<{ readonly at: At } | undefined> => {
75
+ const repo = splat === '' ? await cached(client, repoAt(place)) : undefined;
76
+ if (repo === null) return undefined;
77
+
78
+ const at =
79
+ repo === undefined
80
+ ? await atOf(client, place, splat)
81
+ : { ...place, ref: { name: repo.defaultBranch, kind: 'branch' as const }, path: '' };
82
+ if (at === undefined) return undefined;
83
+
84
+ const read = await cachedPages(client, history(place, at.ref, at.path));
85
+
86
+ return read.pages[0] === null ? undefined : { at };
87
+ };
88
+
89
+ /** A commit on its own page: what its author wrote, and the commits it follows. */
90
+ export interface Commit {
91
+ readonly sha: string;
92
+ readonly tree: string;
93
+ readonly message: string;
94
+ readonly author: string;
95
+ readonly authored: string;
96
+ readonly committer: string;
97
+ readonly committed: string;
98
+ readonly parents: readonly string[];
99
+ }
100
+
101
+ /** The commit `oid`, without its diff: one call, or `null` where none is. */
102
+ export const commitAt = (place: RepoPlace, oid: string) =>
103
+ queryOptions({
104
+ queryKey: ['commit', place.owner, place.repo, oid],
105
+ queryFn: async (): Promise<Commit | null> => {
106
+ const answer = await github.GET('/repos/{owner}/{repo}/git/commits/{commit_sha}', {
107
+ params: { path: { ...place, commit_sha: oid } },
108
+ });
109
+ if ([404, 422].includes(answer.response.status)) return null;
110
+
111
+ if (answer.data === undefined) {
112
+ throw new Error(`The commit didn't load (${answer.response.status})`);
113
+ }
114
+
115
+ const commit = answer.data;
116
+
117
+ return {
118
+ sha: commit.sha,
119
+ tree: commit.tree.sha,
120
+ message: commit.message,
121
+ author: commit.author.name,
122
+ authored: commit.author.date,
123
+ committer: commit.committer.name,
124
+ committed: commit.committer.date,
125
+ parents: commit.parents.map((parent) => parent.sha),
126
+ };
127
+ },
128
+ staleTime: Infinity,
129
+ });