ref0-git 0.0.0-stage → 0.2.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 +122 -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 +547 -0
  197. package/app/apps/github/src/palette/recent.ts +116 -0
  198. package/app/apps/github/src/palette/rows.tsx +455 -0
  199. package/app/apps/github/src/palette/server.ts +104 -0
  200. package/app/apps/github/src/palette/targets.ts +306 -0
  201. package/app/apps/github/src/policy.ts +600 -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 +538 -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 +48 -0
  336. package/dist/cli/helpers.mjs +51 -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 +79 -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 +75 -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 +205 -0
  368. package/dist/init/node-app.mjs +189 -0
  369. package/dist/init/node.mjs +458 -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 +383 -0
  382. package/dist/init/versions.mjs +32 -0
  383. package/dist/init/workspace.mjs +20 -0
  384. package/package.json +52 -3
  385. package/README.md +0 -3
@@ -0,0 +1,293 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { cn } from '#/lib/cn';
3
+ import type { LucideIcon } from 'lucide-react';
4
+
5
+ import { Go } from '../code/controls.tsx';
6
+ import type { RepoPlace } from '../code/places.ts';
7
+ import type { Repo } from '../code/repo.ts';
8
+ import { Count } from '../components/count.tsx';
9
+ import { HotkeyHint, Keys, hotkeys } from '../components/hotkeys/hotkeys.tsx';
10
+ import { type Section, sectionIcon } from '../components/shell/sections.ts';
11
+ import {
12
+ SidebarGroup,
13
+ SidebarMenu,
14
+ SidebarMenuBadge,
15
+ SidebarMenuButton,
16
+ SidebarMenuItem,
17
+ } from '../components/ui/sidebar.tsx';
18
+ import type { PageOperation } from '../clients/allowed.ts';
19
+ import { allowedHere } from '../hooks/allowed.ts';
20
+ import { tabCounts, tabQueries } from '../issues/counts.ts';
21
+ import { defaultQuery, filterOf, searchQueryOf } from '../issues/search.ts';
22
+ import { ownerProblem } from '../names/owners.ts';
23
+ import { defaultPullQuery, pullFilterOf, pullSearchQueryOf } from '../pulls/search.ts';
24
+ import { settingsOpen } from '../settings/settings-layout.tsx';
25
+ import { inInbox } from '../inbox/inbox-item.tsx';
26
+
27
+ /** What the sidebar's items point at: an owner, the org level, or one of its repos. */
28
+ export interface Place {
29
+ readonly owner: string;
30
+ readonly repo?: string;
31
+ }
32
+
33
+ /** Each section's name, icon and keys: Code is Repositories at the org level. */
34
+ const sections: readonly {
35
+ readonly section: Section;
36
+ readonly name: (place: Place) => string;
37
+ readonly icon: (place: Place) => LucideIcon;
38
+ /** The keys that lead to it, as GitHub's `g i` and `g p` do. */
39
+ readonly hotkey?: string;
40
+ }[] = [
41
+ {
42
+ section: 'code',
43
+ name: (place) => (place.repo === undefined ? 'Repositories' : 'Code'),
44
+ icon: (place) => sectionIcon('code', place.repo !== undefined),
45
+ },
46
+ {
47
+ section: 'issues',
48
+ name: () => 'Issues',
49
+ icon: () => sectionIcon('issues', false),
50
+ hotkey: hotkeys.issues,
51
+ },
52
+ {
53
+ section: 'pulls',
54
+ name: () => 'Pull requests',
55
+ icon: () => sectionIcon('pulls', false),
56
+ hotkey: hotkeys.pulls,
57
+ },
58
+ { section: 'releases', name: () => 'Releases', icon: () => sectionIcon('releases', false) },
59
+ { section: 'tokens', name: () => 'Tokens', icon: () => sectionIcon('tokens', false) },
60
+ { section: 'settings', name: () => 'Settings', icon: () => sectionIcon('settings', false) },
61
+ ];
62
+
63
+ /** A repo's first segments after its name that are each section's: any other page is Code's. */
64
+ const repoSegments: ReadonlyMap<string, Section> = new Map([
65
+ ['issues', 'issues'],
66
+ ['labels', 'issues'],
67
+ ['pulls', 'pulls'],
68
+ ['pull', 'pulls'],
69
+ ['compare', 'pulls'],
70
+ ['queue', 'pulls'],
71
+ ['releases', 'releases'],
72
+ ['tags', 'releases'],
73
+ ['tokens', 'tokens'],
74
+ ['settings', 'settings'],
75
+ ]);
76
+
77
+ const nothing: ReadonlySet<PageOperation> = new Set();
78
+
79
+ /** `path`'s segments, without its query or fragment. */
80
+ const segmentsOf = (path: string) => path.split(/[?#]/)[0]?.split('/').filter(Boolean) ?? [];
81
+
82
+ /**
83
+ * What `path` is a page of: an owner's org level, under `/orgs/$owner/` or at `/$owner`, or one of
84
+ * its repos. The app's own pages, such as `/` and `/new`, are the viewer's, and a visitor's are
85
+ * no one's.
86
+ */
87
+ export const placeOf = (path: string, viewer: string | undefined): Place | undefined => {
88
+ const [first, second] = segmentsOf(path);
89
+ if (first === 'orgs' && second !== undefined) return { owner: second };
90
+
91
+ if (first === undefined || ownerProblem(first) !== undefined) {
92
+ return viewer === undefined ? undefined : { owner: viewer };
93
+ }
94
+
95
+ return second === undefined ? { owner: first } : { owner: first, repo: second };
96
+ };
97
+
98
+ /** The section `path` is in, at its level: any page no other section holds is Code's. */
99
+ export const sectionOf = (path: string): Section => {
100
+ const [first, , third] = segmentsOf(path);
101
+ const orgs: readonly string[] = ['issues', 'pulls', 'releases', 'tokens', 'settings'];
102
+ if (first === 'settings') return 'settings';
103
+
104
+ if (first === 'orgs') {
105
+ return orgs.find((section): section is Section => section === third) ?? 'code';
106
+ }
107
+
108
+ return (third === undefined ? undefined : repoSegments.get(third)) ?? 'code';
109
+ };
110
+
111
+ const segment = encodeURIComponent;
112
+
113
+ /**
114
+ * Where `section` is at `place`: a repo's own page, or its org's under `/orgs/$owner/`, so no
115
+ * org page clashes with a repo of the same name. The viewer's repositories are their home, `/`,
116
+ * and their own settings `/settings`, as GitHub's are.
117
+ */
118
+ export const sectionHref = (place: Place, section: Section, viewer: string | undefined) => {
119
+ const owner = segment(place.owner);
120
+
121
+ if (place.repo !== undefined) {
122
+ const home = `/${owner}/${segment(place.repo)}`;
123
+
124
+ return section === 'code' ? home : `${home}/${section}`;
125
+ }
126
+
127
+ if (section === 'settings' && place.owner === viewer) return '/settings';
128
+
129
+ if (section !== 'code') return `/orgs/${owner}/${section}`;
130
+
131
+ return place.owner === viewer ? '/' : `/${owner}`;
132
+ };
133
+
134
+ /**
135
+ * The page's heading, for a page that draws none of its own: its section and its place, such as
136
+ * "Issues · acme/web", or the place alone for its Code or Repositories. The viewer's home, `/`,
137
+ * lists their orgs' repos beside their own, so it's Repositories, not theirs alone.
138
+ */
139
+ export const headingOf = (
140
+ place: Place | undefined,
141
+ section: Section,
142
+ viewer: string | undefined,
143
+ path: string,
144
+ ) => {
145
+ if (place === undefined) return 'Git';
146
+
147
+ if (segmentsOf(path).length === 0) return 'Repositories';
148
+
149
+ const named = place.repo === undefined ? place.owner : `${place.owner}/${place.repo}`;
150
+
151
+ if (section !== 'code') {
152
+ const shown = sections.find((each) => each.section === section);
153
+
154
+ return `${shown?.name(place) ?? section} · ${named}`;
155
+ }
156
+
157
+ return place.repo === undefined && place.owner === viewer ? 'Your repositories' : named;
158
+ };
159
+
160
+ /**
161
+ * A repo's open issues and pull requests, as each list's own Open tab counts them, under the same
162
+ * keys, so the list opens with its counts already read; none at the org level, or with issues
163
+ * switched off.
164
+ */
165
+ const useOpenCounts = (place: RepoPlace | undefined, repo: Repo | undefined) => {
166
+ const issues = useQuery(
167
+ tabCounts(
168
+ place ?? { owner: '', repo: '' },
169
+ 'issues',
170
+ place !== undefined && repo?.hasIssues === true
171
+ ? tabQueries((state) => searchQueryOf(place, { ...filterOf(defaultQuery), state }))
172
+ : undefined,
173
+ ),
174
+ );
175
+ const pulls = useQuery(
176
+ tabCounts(
177
+ place ?? { owner: '', repo: '' },
178
+ 'pulls',
179
+ place === undefined
180
+ ? undefined
181
+ : tabQueries((state) =>
182
+ pullSearchQueryOf(place, {
183
+ ...pullFilterOf(defaultPullQuery),
184
+ state,
185
+ merged: undefined,
186
+ }),
187
+ ),
188
+ ),
189
+ );
190
+
191
+ return { issues: issues.data?.open, pulls: pulls.data?.open };
192
+ };
193
+
194
+ /**
195
+ * The sidebar's items, the same at every level, in the same order: Repositories, or Code inside a
196
+ * repo, then Issues, Pull requests, Releases, Tokens and Settings, each pointing at the org or at
197
+ * the repo, the current one marked. Tokens and Settings are a signed-in person's, another
198
+ * person's level has no Settings, and a repo's Settings show only to those who may change them. Inside a repo, Issues and Pull requests show
199
+ * their open counts at their end, where their keys show while ⌘ is held. A count that hasn't come,
200
+ * or failed, leaves the end empty; the org level has no counts to show.
201
+ */
202
+ export function Nav({
203
+ place,
204
+ person,
205
+ repo,
206
+ path,
207
+ viewer,
208
+ }: {
209
+ readonly place: Place | undefined;
210
+ /** Whether `place`'s owner is another person, whose settings are theirs alone to see. */
211
+ readonly person: boolean;
212
+ /** The repo `place` names, once its layout has read it. */
213
+ readonly repo: Repo | undefined;
214
+ readonly path: string;
215
+ readonly viewer: string | undefined;
216
+ }) {
217
+ const at = place ?? { owner: viewer ?? '' };
218
+ const inRepo = at.repo === undefined ? undefined : { owner: at.owner, repo: at.repo };
219
+ // What the viewer may do in the repo, as its layout read it: nothing is asked at the org level.
220
+ const allowed =
221
+ useQuery({ ...allowedHere(inRepo ?? { owner: '', repo: '' }), enabled: inRepo !== undefined })
222
+ .data ?? nothing;
223
+ const counts = useOpenCounts(inRepo, repo);
224
+ // The Inbox is the viewer's own, in none of the owner's sections.
225
+ const current = inInbox(path) ? undefined : sectionOf(path);
226
+ const shown = sections.filter(({ section }) => {
227
+ if (section === 'tokens') return viewer !== undefined;
228
+
229
+ if (section === 'settings')
230
+ return inRepo === undefined ? viewer !== undefined && !person : settingsOpen(allowed);
231
+
232
+ return true;
233
+ });
234
+ const countOf = (section: Section) =>
235
+ section === 'issues' || section === 'pulls' ? counts[section] : undefined;
236
+
237
+ return (
238
+ <SidebarGroup>
239
+ {/* Folded to icons, they sit 8px apart, each 18px, so they're as far apart as the open rows. */}
240
+ <SidebarMenu
241
+ aria-label={inRepo === undefined ? 'Owner' : 'Repository'}
242
+ className="group-data-[collapsible=icon]:gap-2"
243
+ >
244
+ {shown.map(({ section, name, icon: iconOf, hotkey }) => {
245
+ const Icon = iconOf(at);
246
+ const count = inRepo === undefined ? undefined : countOf(section);
247
+
248
+ return (
249
+ <SidebarMenuItem key={section}>
250
+ <SidebarMenuButton
251
+ // Folded to icons, the keys show in the item's tooltip, as its end is hidden then.
252
+ tooltip={{
253
+ children:
254
+ hotkey === undefined ? (
255
+ name(at)
256
+ ) : (
257
+ <>
258
+ {name(at)}
259
+ <Keys keys={hotkey} />
260
+ </>
261
+ ),
262
+ }}
263
+ isActive={section === current}
264
+ className={cn(
265
+ 'group-data-[collapsible=icon]:[&_svg]:size-4.5',
266
+ // The name stops short of the end's widest, two keys, so neither covers it.
267
+ hotkey !== undefined && 'group-has-data-[sidebar=menu-badge]/menu-item:pr-14',
268
+ )}
269
+ render={
270
+ <Go
271
+ href={sectionHref(at, section, viewer)}
272
+ aria-current={section === current ? 'page' : undefined}
273
+ data-hotkey={hotkey}
274
+ />
275
+ }
276
+ >
277
+ <Icon aria-hidden />
278
+ <span className="truncate">{name(at)}</span>
279
+ </SidebarMenuButton>
280
+ {hotkey !== undefined && (
281
+ <SidebarMenuBadge>
282
+ <HotkeyHint keys={hotkey}>
283
+ {count !== undefined && <Count value={count} />}
284
+ </HotkeyHint>
285
+ </SidebarMenuBadge>
286
+ )}
287
+ </SidebarMenuItem>
288
+ );
289
+ })}
290
+ </SidebarMenu>
291
+ </SidebarGroup>
292
+ );
293
+ }
@@ -0,0 +1,107 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ import {
3
+ createMemoryHistory,
4
+ createRootRouteWithContext,
5
+ createRoute,
6
+ createRouter,
7
+ RouterProvider,
8
+ } from '@tanstack/react-router';
9
+ import { createElement } from 'react';
10
+ import { createRoot, type Root } from 'react-dom/client';
11
+ import { expect, vi } from 'vite-plus/test';
12
+
13
+ import { untilFileEnd } from '#/lib/testing/roots';
14
+
15
+ import type { Viewer } from '../signin/viewer.ts';
16
+ import { Route as AppRoot } from './__root.tsx';
17
+
18
+ /** What a test's `github.GET` is asked. */
19
+ export interface Init {
20
+ readonly params?: { readonly path?: Readonly<Record<string, string>> };
21
+ }
22
+
23
+ /** What the drop-in answers: a found login, or a 404. */
24
+ export interface Answer {
25
+ readonly data: unknown;
26
+ readonly response: Response;
27
+ }
28
+
29
+ /** The drop-in's people: acme is an org with `web` and `cli`, mo a person, and no one else. */
30
+ export const answer = async (path: string, init?: Init): Promise<Answer> => {
31
+ const login = init?.params?.path?.['org'] ?? init?.params?.path?.['username'];
32
+ const found =
33
+ (path === '/orgs/{org}' && login === 'acme') ||
34
+ (path === '/users/{username}' && login === 'mo');
35
+
36
+ if (path === '/orgs/{org}/repos') {
37
+ return {
38
+ data: ['web', 'cli'].map((name) => ({ name, full_name: `acme/${name}`, private: false })),
39
+ response: new Response(null),
40
+ };
41
+ }
42
+
43
+ return found
44
+ ? { data: { login }, response: new Response(null) }
45
+ : { data: undefined, response: new Response(null, { status: 404 }) };
46
+ };
47
+
48
+ const drawn: Root[] = [];
49
+
50
+ /** Unmounts every shell drawn so far. */
51
+ export const undraw = () => {
52
+ for (const root of drawn.splice(0)) root.unmount();
53
+ };
54
+
55
+ /**
56
+ * The app's own shell at `path`, for `viewer`, or signed out for `null`, over any page, and a page
57
+ * at `/own` that draws its own heading. Resolves once the shell has drawn. React's act stays off, as in a browser: it would
58
+ * wait on an open menu's frames, which never end. A test opens one popup at most, and leaves it
59
+ * open: under happy-dom, closing one, or opening another after it, never returns.
60
+ */
61
+ export const drawShell = async (path: string, viewer: Viewer | null) => {
62
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', false);
63
+ const component = AppRoot.options.component;
64
+ if (component === undefined) throw new Error('The app draws no root');
65
+
66
+ const root = createRootRouteWithContext<{ queryClient: QueryClient }>()({
67
+ beforeLoad: () => ({ viewer, signInEnded: false }),
68
+ component,
69
+ });
70
+ const own = createRoute({
71
+ getParentRoute: () => root,
72
+ path: 'own',
73
+ staticData: { ownHeading: true },
74
+ component: () => createElement('h1', null, 'Its own'),
75
+ });
76
+ const anywhere = createRoute({ getParentRoute: () => root, path: '$', component: () => null });
77
+ const router = createRouter({
78
+ routeTree: root.addChildren([own, anywhere]),
79
+ history: createMemoryHistory({ initialEntries: [path] }),
80
+ context: { queryClient: new QueryClient({ defaultOptions: { queries: { retry: false } } }) },
81
+ });
82
+ const container = document.createElement('div');
83
+ document.body.append(container);
84
+ const drawing = untilFileEnd(createRoot(container));
85
+ drawing.render(createElement(RouterProvider, { router }));
86
+ drawn.push(drawing);
87
+
88
+ // A viewer's shell has its owner switcher, and a visitor's its Sign in.
89
+ await vi.waitFor(() =>
90
+ viewer === null
91
+ ? expect(container.textContent).toContain('Sign in')
92
+ : expect(container.querySelector('[aria-label="Switch owner"]')).not.toBeNull(),
93
+ );
94
+
95
+ return { container, router };
96
+ };
97
+
98
+ /** The owner row's name and what it says the owner is, such as "acmeOrganization". */
99
+ export const ownerRow = (container: HTMLElement) =>
100
+ container.querySelector('a[href^="/"] .grid')?.textContent;
101
+
102
+ /** The open popup's items of `role`: each one's text and where it leads. */
103
+ export const items = (role: string) =>
104
+ [...document.querySelectorAll(`[role="${role}"]`)].map((item) => [
105
+ item.textContent,
106
+ item.getAttribute('href'),
107
+ ]);
@@ -0,0 +1,225 @@
1
+ import { type QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-query';
2
+ import {
3
+ createRootRouteWithContext,
4
+ HeadContent,
5
+ Outlet,
6
+ Scripts,
7
+ useLocation,
8
+ useMatch,
9
+ useMatches,
10
+ useRouter,
11
+ } from '@tanstack/react-router';
12
+ import { useEffect } from 'react';
13
+
14
+ import { onSessionEnded } from '../clients/session-ended.ts';
15
+ import { refsStaleOnFocus } from '../code/refs.ts';
16
+ import { canSave, forgetEverySaved, forgetSaved, saveAs } from '../code/saved.ts';
17
+ import fileIconStyles from '../components/file-icons/file-icons.css?url';
18
+ import { AppShell, standsAlone } from '../components/shell/app-shell.tsx';
19
+ import { RepoSwitcher } from '../components/shell/repo-switcher.tsx';
20
+ import { NotFound } from '../components/states/states.tsx';
21
+ import { ThemeProvider, themeScript } from '../components/theme-provider.tsx';
22
+ import { prefetchPicturesWhenIdle } from '../components/user-avatar.tsx';
23
+ import { Toaster } from '../components/ui/sonner.tsx';
24
+ import { TooltipProvider } from '../components/ui/tooltip.tsx';
25
+ import markdownStyles from '../components/markdown/markdown.css?url';
26
+ import styles from '../components/ui/styles.css?url';
27
+ import { type Owner, ownerAt } from '../hooks/repos.ts';
28
+ import { forgetViewer, viewerOf, viewerQuery } from '../hooks/viewer.ts';
29
+ import { useAskBeforeLosingDrafts } from '../pulls/review.ts';
30
+ import { InboxItem } from '../inbox/inbox-item.tsx';
31
+ import { usePalette } from '../palette/palette.tsx';
32
+ import { forgetRecentPlaces } from '../palette/recent.ts';
33
+ import { onSignedOut, onSignOut } from '../signin/auth-client.ts';
34
+ import { headingOf, Nav, placeOf, sectionHref, sectionOf } from './-nav.tsx';
35
+
36
+ export const Route = createRootRouteWithContext<{ queryClient: QueryClient }>()({
37
+ head: () => ({
38
+ meta: [
39
+ { charSet: 'utf-8' },
40
+ { name: 'viewport', content: 'width=device-width, initial-scale=1' },
41
+ { title: 'Git' },
42
+ ],
43
+ links: [
44
+ { rel: 'stylesheet', href: styles },
45
+ { rel: 'stylesheet', href: markdownStyles },
46
+ { rel: 'stylesheet', href: fileIconStyles },
47
+ ],
48
+ }),
49
+ // Every navigation runs this: the viewer comes from the cache once the page load has read it.
50
+ beforeLoad: async ({ context }) => {
51
+ const { viewer, ended } = await viewerOf(context.queryClient);
52
+ // The browser keeps a public repo's trees and files for whoever the page is for (F11).
53
+ if (canSave()) saveAs(context.queryClient, viewer?.login ?? null);
54
+
55
+ return { viewer, signInEnded: ended };
56
+ },
57
+ component: Root,
58
+ notFoundComponent: () => <NotFound />,
59
+ });
60
+
61
+ /**
62
+ * The sidenav, beside whichever page the URL names, but the sign-in pages, which stand alone. A
63
+ * call whose session ended forgets the viewer and the reads the browser saved for them, and
64
+ * reloads the route's context, whose `viewing` then reads a visitor whose sign-in ended. A
65
+ * sign-out drops those saved reads too, before it ends the session, then names no one once it has
66
+ * ended, and a page that says a sign-in ended drops every account's. The palette's recent places go
67
+ * each of those ways too.
68
+ */
69
+ function Shell() {
70
+ const { viewer, signInEnded, queryClient } = Route.useRouteContext();
71
+ const router = useRouter();
72
+ const location = useLocation();
73
+ useEffect(
74
+ () =>
75
+ onSessionEnded(() => {
76
+ forgetViewer(queryClient);
77
+ void forgetSaved(queryClient);
78
+ forgetRecentPlaces();
79
+ void router.invalidate();
80
+ }),
81
+ [queryClient, router],
82
+ );
83
+ useEffect(
84
+ () =>
85
+ onSignOut(async () => {
86
+ forgetRecentPlaces();
87
+ await forgetSaved(queryClient);
88
+ }),
89
+ [queryClient],
90
+ );
91
+ // Once the session has ended, the page is a visitor's while the browser goes home.
92
+ useEffect(
93
+ () =>
94
+ onSignedOut(() => {
95
+ queryClient.setQueryData(viewerQuery.queryKey, { viewer: null, ended: false });
96
+ void router.invalidate();
97
+ }),
98
+ [queryClient, router],
99
+ );
100
+ // A page load that learns the sign-in ended can't tell whose saved reads they were.
101
+ useEffect(() => {
102
+ if (signInEnded) forgetRecentPlaces();
103
+
104
+ if (signInEnded && canSave()) void forgetEverySaved(queryClient);
105
+ }, [signInEnded, queryClient]);
106
+ useEffect(() => refsStaleOnFocus(queryClient), [queryClient]);
107
+ useEffect(() => prefetchPicturesWhenIdle(), []);
108
+ const loaded = useMatch({ from: '/$owner/$repo', shouldThrow: false })?.loaderData?.repo;
109
+ const ownHeading = useMatches({
110
+ select: (matches) => matches.some((match) => match.staticData.ownHeading === true),
111
+ });
112
+ // Where the page is, as its URL says, and the section it's in, which every link keeps.
113
+ const login = viewer?.login;
114
+ const place = placeOf(location.pathname, login);
115
+ const section = sectionOf(location.pathname);
116
+ // The owner, as the route that names it read it before the page drew: the viewer is known.
117
+ const named = useQuery({
118
+ ...ownerAt(place?.owner ?? '', login),
119
+ enabled: place !== undefined && place.owner !== login,
120
+ }).data;
121
+ const repo =
122
+ loaded !== undefined && loaded.owner === place?.owner && loaded.name === place.repo
123
+ ? loaded
124
+ : undefined;
125
+ const palette = usePalette(
126
+ viewer === null || viewer === undefined
127
+ ? undefined
128
+ : {
129
+ here: {
130
+ owner: place?.owner,
131
+ org: place !== undefined && place.owner !== viewer.login && named?.kind === 'org',
132
+ repo: place?.repo,
133
+ defaultBranch: repo?.defaultBranch,
134
+ },
135
+ viewer: viewer.login,
136
+ orgs: viewer.orgs,
137
+ cloneUrl: repo?.cloneUrl,
138
+ ownerHref: (next) => sectionHref({ owner: next }, section, login),
139
+ },
140
+ location.pathname,
141
+ );
142
+ if (standsAlone(location.href)) return <Outlet />;
143
+
144
+ // A person, until the owner's read says otherwise, or if it failed.
145
+ const ownerOf = (owner: string): Owner => {
146
+ if (owner === login) return { kind: 'viewer', login: owner };
147
+
148
+ return named ?? { kind: 'user', login: owner };
149
+ };
150
+
151
+ const owner = place === undefined ? undefined : ownerOf(place.owner);
152
+
153
+ return (
154
+ <AppShell
155
+ viewer={login}
156
+ ended={signInEnded}
157
+ owner={
158
+ owner === undefined
159
+ ? undefined
160
+ : { login: owner.login, account: owner.kind === 'org' ? 'org' : 'user' }
161
+ }
162
+ owners={viewer === null ? [] : [viewer.login, ...viewer.orgs]}
163
+ repo={place?.repo}
164
+ ownerHref={(next) => sectionHref({ owner: next }, section, login)}
165
+ repoHref={(next, name) => sectionHref({ owner: next, repo: name }, section, login)}
166
+ nav={
167
+ <Nav
168
+ place={place}
169
+ person={owner?.kind === 'user'}
170
+ repo={repo}
171
+ path={location.pathname}
172
+ viewer={login}
173
+ />
174
+ }
175
+ switcher={
176
+ owner === undefined ? undefined : (
177
+ <RepoSwitcher
178
+ owner={owner}
179
+ current={place?.repo}
180
+ hrefOf={(name) =>
181
+ sectionHref(
182
+ name === undefined ? { owner: owner.login } : { owner: owner.login, repo: name },
183
+ section,
184
+ login,
185
+ )
186
+ }
187
+ signedIn={login !== undefined}
188
+ />
189
+ )
190
+ }
191
+ heading={ownHeading ? undefined : headingOf(place, section, login, location.pathname)}
192
+ path={location.href}
193
+ palette={palette}
194
+ inbox={login === undefined ? undefined : <InboxItem path={location.href} />}
195
+ >
196
+ <Outlet />
197
+ </AppShell>
198
+ );
199
+ }
200
+
201
+ function Root() {
202
+ const { queryClient } = Route.useRouteContext();
203
+ useAskBeforeLosingDrafts(queryClient);
204
+
205
+ return (
206
+ // The inline script sets <html>'s theme class before React hydrates, so React leaves it be.
207
+ <html lang="en" suppressHydrationWarning>
208
+ <head>
209
+ <script dangerouslySetInnerHTML={{ __html: themeScript }} />
210
+ <HeadContent />
211
+ </head>
212
+ <body>
213
+ <ThemeProvider defaultTheme="system">
214
+ <TooltipProvider>
215
+ <QueryClientProvider client={queryClient}>
216
+ <Shell />
217
+ </QueryClientProvider>
218
+ <Toaster />
219
+ </TooltipProvider>
220
+ </ThemeProvider>
221
+ <Scripts />
222
+ </body>
223
+ </html>
224
+ );
225
+ }
@@ -0,0 +1,18 @@
1
+ import { createFileRoute } from '@tanstack/react-router';
2
+
3
+ import type { AppContext } from '../context/context.ts';
4
+
5
+ /**
6
+ * Better Auth's routes, or a 404 for a path with an empty segment. better-call 1.4.5 refuses one
7
+ * too; the guard keeps it refused if a later router reads `//sign-in/email` as `/sign-in/email`,
8
+ * past `disabledPaths` (GHSA-x732).
9
+ */
10
+ const served = ({ request, context }: { request: Request; context: AppContext }) =>
11
+ new URL(request.url).pathname.includes('//')
12
+ ? Promise.resolve(new Response('Not Found', { status: 404 }))
13
+ : context.auth(request);
14
+
15
+ /** Sign-up, sign-in and sign-out, as Better Auth serves them. */
16
+ export const Route = createFileRoute('/api/auth/$')({
17
+ server: { handlers: { GET: served, POST: served } },
18
+ });
@@ -0,0 +1,10 @@
1
+ import { createFileRoute } from '@tanstack/react-router';
2
+
3
+ import { forwardDownload } from '../../../../clients/transfers.ts';
4
+
5
+ /** An asset's bytes, streamed from the drop-in as the session's holder, for a plain link. */
6
+ export const Route = createFileRoute('/downloads/$owner/$repo/$asset')({
7
+ server: {
8
+ handlers: { GET: ({ request, context, params }) => forwardDownload(context, request, params) },
9
+ },
10
+ });
@@ -0,0 +1,21 @@
1
+ import { createFileRoute } from '@tanstack/react-router';
2
+
3
+ import { fileIconSprite } from '../components/file-icons/file-icons.tsx';
4
+
5
+ /**
6
+ * The file icons' symbols, one file the browser keeps, which each `FileIcon` draws from, so no page
7
+ * carries them. Its link names what it holds, so the browser keeps it for good.
8
+ */
9
+ export const Route = createFileRoute('/file-icons.svg')({
10
+ server: {
11
+ handlers: {
12
+ GET: () =>
13
+ new Response(fileIconSprite(), {
14
+ headers: {
15
+ 'content-type': 'image/svg+xml; charset=utf-8',
16
+ 'cache-control': 'public, max-age=31536000, immutable',
17
+ },
18
+ }),
19
+ },
20
+ },
21
+ });