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,110 @@
1
+ import { hashKey, type QueryClient, type QueryKey } from '@tanstack/react-query';
2
+ import * as Option from 'effect/Option';
3
+ import * as Schema from 'effect/Schema';
4
+
5
+ import type { RepoPlace } from './places.ts';
6
+ import { repoAt } from './repo.ts';
7
+ import { dropEveryAccount, indexedReads, type Savable, type SavedReads } from './saved-reads.ts';
8
+
9
+ /**
10
+ * What the app saves of what a page read, as the persisted-cache threat records bind it: only a
11
+ * tree or a file at a commit, which never changes, of a repo that answered `private: false`. So
12
+ * what's on disk is what any visitor could read, and nothing a revoke must reach is kept: no
13
+ * private repo's reads, no list, issue, comment or pull request, no permission and no viewer.
14
+ */
15
+
16
+ /** A saved read's key: a tree's or a file's, at a commit, `[kind, owner, repo, sha, path]`. */
17
+ const savedKeyOf = Schema.decodeUnknownOption(
18
+ Schema.Tuple([
19
+ Schema.Literals(['tree', 'file']),
20
+ Schema.String,
21
+ Schema.String,
22
+ Schema.String,
23
+ Schema.String,
24
+ ]),
25
+ );
26
+
27
+ interface Saving {
28
+ readonly account: string | null;
29
+ readonly reads: SavedReads;
30
+ readonly stop: () => void;
31
+ }
32
+
33
+ /** Each page's saving, by its Query client: none on the server, in tests, or before `saveAs`. */
34
+ const savings = new WeakMap<QueryClient, Saving>();
35
+
36
+ /** Whether this page can save reads: a browser's, with IndexedDB. */
37
+ export const canSave = () => 'indexedDB' in globalThis;
38
+
39
+ /**
40
+ * Saves the reads `client` makes, for `account`, or a visitor's for `null`, from now on. A page
41
+ * calls it as it learns who it's for; an account it already saves for changes nothing.
42
+ */
43
+ export const saveAs = (client: QueryClient, account: string | null) => {
44
+ const held = savings.get(client);
45
+ if (held?.account === account) return;
46
+
47
+ held?.stop();
48
+ const reads = indexedReads(account);
49
+ const stop = client.getQueryCache().subscribe((event) => {
50
+ if (event.type !== 'updated' || event.action.type !== 'success') return;
51
+
52
+ // Only a public repo's tree or file: its repo's read says so.
53
+ const key = savedKeyOf(event.query.queryKey);
54
+ if (Option.isNone(key)) return;
55
+
56
+ const [, owner, repo] = key.value;
57
+ const now = client.getQueryData(repoAt({ owner, repo }).queryKey);
58
+ const value = client.getQueryData<Savable | null>(key.value);
59
+ if (now?.private !== false || value === undefined || value === null) return;
60
+
61
+ void reads.put(`${owner}/${repo}`, event.query.queryHash, value);
62
+ });
63
+ savings.set(client, { account, reads, stop });
64
+ };
65
+
66
+ /**
67
+ * Drops the account's saved reads and stops saving, as on sign-out or once its session ends: the
68
+ * page's next navigation saves for whoever it's for then.
69
+ */
70
+ export const forgetSaved = async (client: QueryClient) => {
71
+ const held = savings.get(client);
72
+ if (held === undefined) return;
73
+
74
+ held.stop();
75
+ savings.delete(client);
76
+ await held.reads.clear();
77
+ };
78
+
79
+ /**
80
+ * Drops every saved read and stops saving, as once a page load learns its sign-in ended: it
81
+ * can't tell whose they were, so none is kept.
82
+ */
83
+ export const forgetEverySaved = async (client: QueryClient) => {
84
+ await forgetSaved(client);
85
+ await dropEveryAccount();
86
+ };
87
+
88
+ /**
89
+ * Before a page reads `key`, which nothing in memory holds, gives `draw` its saved read, but only
90
+ * once the repo's read now says it's still public: one it now can't read, or reads as private,
91
+ * drops its saved reads instead. So a restore never draws what a revoke reached.
92
+ */
93
+ export const restore = async (
94
+ client: QueryClient,
95
+ place: RepoPlace,
96
+ key: QueryKey,
97
+ draw: (value: Savable) => void,
98
+ ) => {
99
+ const held = savings.get(client);
100
+ if (held === undefined || client.getQueryState(key)?.data !== undefined) return;
101
+
102
+ const repo = `${place.owner}/${place.repo}`;
103
+ const now = await client.query(repoAt(place)).catch(() => undefined);
104
+ if (now === undefined) return;
105
+
106
+ if (now === null || now.private) return held.reads.drop(repo);
107
+
108
+ const saved = await held.reads.get(repo, hashKey(key));
109
+ if (saved !== undefined) draw(saved);
110
+ };
@@ -0,0 +1,186 @@
1
+ /**
2
+ * How the tree beside a code page moves when a pointer opens or closes a folder. The folder's
3
+ * chevron turns, the rows under it slide from where they stood, and the rows it adds fade in, over
4
+ * 150 ms on ref0's strong ease-out.
5
+ *
6
+ * `@pierre/trees` draws its rows as one flat list, a screen at a time. It reuses a row's element
7
+ * for whichever row then stands there, so there's no folder box whose height could grow. Instead,
8
+ * each row is matched by its path to where the press found it, and only rows drawn move: a folder
9
+ * of 10,000 files moves a screen of rows.
10
+ *
11
+ * Nothing moves from the keyboard, which walks the tree all day, or under reduced motion: the rows
12
+ * stand at once, as motion.md says. A press while rows still slide takes them from where they're
13
+ * seen, so a quick second press turns them back, and none is left partway.
14
+ */
15
+
16
+ /** As long as a dropdown takes to open: a folder's rows arrive in about the same time. */
17
+ const duration = 150;
18
+
19
+ /** ref0's strong ease-out, `--ease-snappy`, for what arrives. */
20
+ const easing = 'cubic-bezier(0.23, 1, 0.32, 1)';
21
+
22
+ /**
23
+ * How long after a press the folder's rows may still arrive: a folder not yet read draws its rows
24
+ * once its read answers, and only then do the rows under it move.
25
+ */
26
+ const settleMs = 1000;
27
+
28
+ /** The chevron's turn, from the way it pointed to where its folder's state now points it. */
29
+ const turned: Readonly<Record<'open' | 'closed', PropertyIndexedKeyframes>> = {
30
+ open: { rotate: ['-90deg', '0deg'] },
31
+ closed: { rotate: ['90deg', '0deg'] },
32
+ };
33
+
34
+ /** What a press on a folder found: the folder, and where each drawn row stood, by its path. */
35
+ interface Press {
36
+ readonly shadow: ShadowRoot;
37
+ readonly folder: string;
38
+ readonly expanded: string | null;
39
+ readonly tops: ReadonlyMap<string, number>;
40
+ readonly at: number;
41
+ chevronTurned: boolean;
42
+ }
43
+
44
+ /** The tree's list of rows, which the rows' places are measured from, since the page may scroll. */
45
+ const listIn = (shadow: ShadowRoot) =>
46
+ shadow.querySelector<HTMLElement>('[data-file-tree-virtualized-list]');
47
+
48
+ /** How far a row is slid now, by a slide still running: none once it stands. */
49
+ const slidBy = (row: HTMLElement) => {
50
+ const transform = getComputedStyle(row).transform;
51
+
52
+ return transform === 'none' ? 0 : new DOMMatrixReadOnly(transform).m42;
53
+ };
54
+
55
+ /**
56
+ * Each row drawn in the list, by its path: where it's seen in the list now, slid or not, and where
57
+ * it stands once it stops. A sticky row over the list copies a row and stands still: it's left out.
58
+ */
59
+ const rowsIn = (shadow: ShadowRoot) => {
60
+ const list = listIn(shadow);
61
+ if (list === null) return new Map<string, { row: HTMLElement; seen: number; top: number }>();
62
+
63
+ const from = list.getBoundingClientRect().top;
64
+
65
+ return new Map(
66
+ [...list.querySelectorAll<HTMLElement>('[data-type="item"][data-item-path]')].flatMap((row) => {
67
+ const path = row.getAttribute('data-item-path');
68
+ if (path === null || row.closest('[data-file-tree-sticky-overlay]') !== null) return [];
69
+
70
+ const seen = row.getBoundingClientRect().top - from;
71
+
72
+ return [[path, { row, seen, top: seen - slidBy(row) }] as const];
73
+ }),
74
+ );
75
+ };
76
+
77
+ /** Starts `keyframes` on `element`, or on its `pseudoElement`, in place of what that was running. */
78
+ const move = (element: Element, keyframes: PropertyIndexedKeyframes, pseudoElement?: '::after') => {
79
+ for (const running of element.getAnimations({ subtree: pseudoElement !== undefined }))
80
+ if (
81
+ running.effect instanceof KeyframeEffect &&
82
+ running.effect.target === element &&
83
+ running.effect.pseudoElement === (pseudoElement ?? null)
84
+ )
85
+ running.cancel();
86
+ element.animate(keyframes, { duration, easing, pseudoElement: pseudoElement ?? null });
87
+ };
88
+
89
+ /** The folder row a press landed on, through the tree's shadow root, if it landed on one. */
90
+ const folderPressed = (event: Event) =>
91
+ event
92
+ .composedPath()
93
+ .find(
94
+ (node): node is HTMLElement =>
95
+ node instanceof HTMLElement && node.getAttribute('data-item-type') === 'folder',
96
+ );
97
+
98
+ /** Moves the rows a press's folder changed, once they've changed; whether they had. */
99
+ const settle = (press: Press) => {
100
+ const rows = rowsIn(press.shadow);
101
+ const folder = rows.get(press.folder);
102
+ if (folder === undefined) return true;
103
+
104
+ const expanded = folder.row.getAttribute('aria-expanded');
105
+
106
+ if (!press.chevronTurned && expanded !== press.expanded) {
107
+ press.chevronTurned = true;
108
+ // The chevron is the row's `::after`, at its right end, as the tree's CSS in code-tree.tsx draws it.
109
+ move(folder.row, expanded === 'true' ? turned.open : turned.closed, '::after');
110
+ }
111
+
112
+ const below = [...rows].filter(([, { top }]) => top > folder.top);
113
+ // Every row under the folder moves by the same rows' height: the first one drawn before says how far.
114
+ const shift = below
115
+ .map(([path, { top }]) => (press.tops.get(path) ?? top) - top)
116
+ .find((each) => Math.abs(each) > 0.5);
117
+ if (shift === undefined) return false;
118
+
119
+ for (const [path, { row, top }] of below) {
120
+ const was = press.tops.get(path);
121
+
122
+ const from = was === undefined ? shift : was - top;
123
+
124
+ if (was === undefined && path.startsWith(press.folder)) {
125
+ move(row, { opacity: [0, 1] });
126
+ } else if (Math.abs(from) > 0.5) {
127
+ move(row, { transform: [`translateY(${from}px)`, 'none'] });
128
+ }
129
+ }
130
+
131
+ return true;
132
+ };
133
+
134
+ /**
135
+ * Moves the tree's rows each time a pointer opens or closes a folder in the tree drawn inside
136
+ * `within`; what it returns stops it.
137
+ */
138
+ export const foldOnPress = (within: HTMLElement) => {
139
+ let press: Press | undefined;
140
+ let watcher: MutationObserver | undefined;
141
+
142
+ const stop = () => {
143
+ watcher?.disconnect();
144
+ watcher = undefined;
145
+ press = undefined;
146
+ };
147
+
148
+ const onChange = () => {
149
+ if (press === undefined) return;
150
+
151
+ if (performance.now() - press.at > settleMs || settle(press)) stop();
152
+ };
153
+
154
+ const onPointerDown = (event: PointerEvent) => {
155
+ stop();
156
+
157
+ if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
158
+
159
+ const folder = folderPressed(event);
160
+ const shadow = folder?.getRootNode();
161
+ const path = folder?.getAttribute('data-item-path');
162
+ if (folder === undefined || !(shadow instanceof ShadowRoot) || path == null) return;
163
+
164
+ // Where each row is seen now, mid-slide or not: the next change slides it on from there.
165
+ const rows = rowsIn(shadow);
166
+ press = {
167
+ shadow,
168
+ folder: path,
169
+ expanded: folder.getAttribute('aria-expanded'),
170
+ tops: new Map([...rows].map(([each, { seen }]) => [each, seen])),
171
+ at: performance.now(),
172
+ chevronTurned: false,
173
+ };
174
+ watcher = new MutationObserver(onChange);
175
+ watcher.observe(shadow, { subtree: true, childList: true, attributes: true });
176
+ };
177
+
178
+ within.addEventListener('pointerdown', onPointerDown, { capture: true });
179
+ within.addEventListener('keydown', stop, { capture: true });
180
+
181
+ return () => {
182
+ stop();
183
+ within.removeEventListener('pointerdown', onPointerDown, { capture: true });
184
+ within.removeEventListener('keydown', stop, { capture: true });
185
+ };
186
+ };
@@ -0,0 +1,136 @@
1
+ import { queryOptions, type QueryClient } from '@tanstack/react-query';
2
+
3
+ import { cached } from '../clients/cached.ts';
4
+ import { github } from '../clients/clients.ts';
5
+ import { ancestry, nameOf, type RepoPlace } from './places.ts';
6
+ import { restore } from './saved.ts';
7
+
8
+ /**
9
+ * A repository's tree, one folder at a time: a page asks for the folders on its path, and the
10
+ * tree for each folder a reader opens, never the whole tree at once. A folder is read by its
11
+ * tree's ID, which never changes, so each is read once.
12
+ */
13
+
14
+ /** What a folder holds: a file, a folder, a submodule's commit, or a symlink, as Git's modes say. */
15
+ export type EntryKind = 'file' | 'folder' | 'submodule' | 'symlink';
16
+
17
+ /** One of a folder's entries. */
18
+ export interface Entry {
19
+ readonly name: string;
20
+ readonly path: string;
21
+ readonly kind: EntryKind;
22
+ readonly sha: string;
23
+ }
24
+
25
+ /** A folder's entries, folders first, each by name, and whether the drop-in cut its list short. */
26
+ export interface Folder {
27
+ readonly path: string;
28
+ readonly sha: string;
29
+ readonly entries: readonly Entry[];
30
+ readonly truncated: boolean;
31
+ }
32
+
33
+ const kindOf = (type: string, mode: string): EntryKind => {
34
+ if (type === 'tree') return 'folder';
35
+
36
+ if (type === 'commit') return 'submodule';
37
+
38
+ return mode === '120000' ? 'symlink' : 'file';
39
+ };
40
+
41
+ const rank = (entry: Entry) => (entry.kind === 'folder' ? 0 : 1);
42
+
43
+ /** Folders first, as GitHub lists them, then by name as Git's bytes sort it. */
44
+ export const byKindThenName = (left: Entry, right: Entry) =>
45
+ rank(left) - rank(right) || (left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
46
+
47
+ /** The folder at `path` whose tree is `sha`: one call, for one level. */
48
+ export const folder = (place: RepoPlace, sha: string, path: string) =>
49
+ queryOptions({
50
+ queryKey: ['tree', place.owner, place.repo, sha, path],
51
+ queryFn: async (): Promise<Folder> => {
52
+ const answer = await github.GET('/repos/{owner}/{repo}/git/trees/{tree_sha}', {
53
+ params: { path: { ...place, tree_sha: sha } },
54
+ });
55
+
56
+ if (answer.data === undefined) {
57
+ throw new Error(`The folder didn't load (${answer.response.status})`);
58
+ }
59
+
60
+ const entries = answer.data.tree.flatMap((item): Entry[] =>
61
+ item.path === undefined || item.sha === undefined
62
+ ? []
63
+ : [
64
+ {
65
+ name: item.path,
66
+ path: path === '' ? item.path : `${path}/${item.path}`,
67
+ kind: kindOf(item.type ?? 'blob', item.mode ?? '100644'),
68
+ sha: item.sha,
69
+ },
70
+ ],
71
+ );
72
+
73
+ return { path, sha, entries: entries.sort(byKindThenName), truncated: answer.data.truncated };
74
+ },
75
+ staleTime: Infinity,
76
+ });
77
+
78
+ /** The folder at `path` whose tree is `sha`, from memory, or saved when this page saves reads. */
79
+ export const readFolder = async (
80
+ client: QueryClient,
81
+ place: RepoPlace,
82
+ sha: string,
83
+ path: string,
84
+ ) => {
85
+ const options = folder(place, sha, path);
86
+ await restore(client, place, options.queryKey, (saved) => {
87
+ if ('entries' in saved) client.setQueryData(options.queryKey, saved);
88
+ });
89
+
90
+ return cached(client, options);
91
+ };
92
+
93
+ /**
94
+ * The root's folder and each folder down to `path`, a call a level, or `undefined` when one on the
95
+ * way, `path` too, isn't a folder: a file's page walks to its parent.
96
+ */
97
+ export const walk = async (
98
+ client: QueryClient,
99
+ place: RepoPlace,
100
+ root: string,
101
+ path: string,
102
+ ): Promise<readonly Folder[] | undefined> => {
103
+ const folders = [await readFolder(client, place, root, '')];
104
+
105
+ for (const step of ancestry(path)) {
106
+ const above = folders.at(-1);
107
+ const entry = above?.entries.find((each) => each.name === nameOf(step));
108
+ if (entry?.kind !== 'folder') return undefined;
109
+
110
+ folders.push(await readFolder(client, place, entry.sha, step));
111
+ }
112
+
113
+ return folders;
114
+ };
115
+
116
+ /** Every file's path under the tree `root`, for Go to file: one call, up to the drop-in's 100,000. */
117
+ export const allFiles = (place: RepoPlace, root: string) =>
118
+ queryOptions({
119
+ queryKey: ['files', place.owner, place.repo, root],
120
+ queryFn: async () => {
121
+ const answer = await github.GET('/repos/{owner}/{repo}/git/trees/{tree_sha}', {
122
+ params: { path: { ...place, tree_sha: root }, query: { recursive: '1' } },
123
+ });
124
+
125
+ if (answer.data === undefined) {
126
+ throw new Error(`The files didn't load (${answer.response.status})`);
127
+ }
128
+
129
+ const paths = answer.data.tree.flatMap((item) =>
130
+ item.type === 'blob' && item.path !== undefined ? [item.path] : [],
131
+ );
132
+
133
+ return { paths, truncated: answer.data.truncated };
134
+ },
135
+ staleTime: Infinity,
136
+ });
@@ -0,0 +1,53 @@
1
+ import { Avatar, Style } from '@dicebear/core';
2
+ import pixelbotStyle from '@dicebear/styles/pixelbot.json' with { type: 'json' };
3
+ import planetsStyle from '@dicebear/styles/planets.json' with { type: 'json' };
4
+
5
+ import { recentOf } from './recent.ts';
6
+ import { type Account, groundOf } from './user-avatar.tsx';
7
+
8
+ // DiceBear's own styles, both CC0 1.0. Each is checked once, here, and reused for every picture.
9
+ const pixelbot = new Style(pixelbotStyle);
10
+
11
+ const planets = new Style(planetsStyle);
12
+
13
+ /**
14
+ * The pictures last drawn, by account and lowercased login. A list shows one login many times, and
15
+ * each page move mounts its avatars again, so each is drawn once and then read from here. A
16
+ * person's is about 27 KB and an org's 6 KB, so 200 keep a long session's to about 5 MB.
17
+ */
18
+ export const drawnMost = 200;
19
+
20
+ const drawn = recentOf<string>(drawnMost);
21
+
22
+ /**
23
+ * A login's picture, drawn in the page from the login, so it's the same every time and needs no
24
+ * avatar service. A person's is DiceBear's Pixelbot in its Cool preset, and an org's its Planets in
25
+ * Cool System. Each sits on its kind's one dark ground, `groundOf`, in either theme. A login's case doesn't change it, as it
26
+ * doesn't change whose it is. Each is drawn once, and kept among the last `drawnMost` drawn.
27
+ *
28
+ * DiceBear checks every style and option it's given, which makes this module about 30 KB gzipped,
29
+ * so `UserAvatar` loads it only once a page draws an avatar.
30
+ */
31
+ export const pictureOf = (login: string, account: Account): string => {
32
+ const seed = login.toLowerCase();
33
+ const key = `${account}:${seed}`;
34
+ const known = drawn.get(key);
35
+ if (known !== undefined) return known;
36
+
37
+ const picture =
38
+ account === 'org'
39
+ ? new Avatar(planets, {
40
+ seed,
41
+ backgroundColor: [groundOf.org.slice(1)],
42
+ planetColor: ['74b160', '39b789', '00b6af', '00b1cf', '47a7e7', '7a9bef'],
43
+ }).toDataUri()
44
+ : new Avatar(pixelbot, {
45
+ seed,
46
+ backgroundColor: [groundOf.user.slice(1)],
47
+ glowColor: ['7dd3fc', '5eead4', 'a5b4fc', 'c4b5fd', '67e8f9'],
48
+ }).toDataUri();
49
+
50
+ drawn.set(key, picture);
51
+
52
+ return picture;
53
+ };
@@ -0,0 +1,16 @@
1
+ /** An avatar's owner: a person's or an org's login, or a repo, by its owner and name. */
2
+ export interface AvatarOf {
3
+ readonly owner: string;
4
+ readonly repo?: string | undefined;
5
+ }
6
+
7
+ /**
8
+ * An avatar's URL on the app's own route, `/icons/{login}` or `/icons/{owner}/{repo}`: its version,
9
+ * when the page knows one, makes it a new URL every image loads.
10
+ */
11
+ export const avatarUrl = (place: AvatarOf, version?: string) => {
12
+ const repo = place.repo === undefined ? '' : `/${encodeURIComponent(place.repo)}`;
13
+ const path = `/icons/${encodeURIComponent(place.owner)}${repo}`;
14
+
15
+ return version === undefined ? path : `${path}?v=${encodeURIComponent(version)}`;
16
+ };
@@ -0,0 +1,100 @@
1
+ import { useState } from 'react';
2
+
3
+ import {
4
+ AlertDialog,
5
+ AlertDialogAction,
6
+ AlertDialogCancel,
7
+ AlertDialogContent,
8
+ AlertDialogDescription,
9
+ AlertDialogFooter,
10
+ AlertDialogHeader,
11
+ AlertDialogTitle,
12
+ AlertDialogTrigger,
13
+ } from './ui/alert-dialog.tsx';
14
+ import { Button } from './ui/button.tsx';
15
+ import { Field, FieldLabel } from './ui/field.tsx';
16
+ import { Input } from './ui/input.tsx';
17
+
18
+ /**
19
+ * A button for something that can't be undone, such as a delete: it asks in an AlertDialog first,
20
+ * and does it only from there. Both buttons say the action and nothing more, such as "Revoke":
21
+ * the confirm is `label` again, or `confirm`, the same verb with its object where the dialog would
22
+ * otherwise be unclear, such as "Delete webhook". The dialog's `title` names the thing, such as
23
+ * "Revoke token-12?", and its `description` says what follows: that it's permanent, what's kept and
24
+ * what stops working. Both buttons are the Button's `destructive` variant, always, so every page's
25
+ * destructive action is red the same way. buttons.test.ts holds every page to these rules. With
26
+ * `mustType`, such as a repo's full name, the confirm waits until that text is typed into the
27
+ * dialog's field `typedId`.
28
+ */
29
+ export function ConfirmAction({
30
+ label,
31
+ title,
32
+ description,
33
+ confirm,
34
+ disabled = false,
35
+ size = 'sm',
36
+ className,
37
+ mustType,
38
+ onConfirm,
39
+ }: {
40
+ /** The action's verb, with its object where the page needs one, such as "Revoke". */
41
+ readonly label: string;
42
+ readonly title: string;
43
+ readonly description: string;
44
+ /** The confirm's text, when it isn't `label`: the same verb, with an object. */
45
+ readonly confirm?: string;
46
+ readonly disabled?: boolean;
47
+ /** The button's size, `sm` by default; `default` beside a dialog's own buttons. */
48
+ readonly size?: 'sm' | 'default';
49
+ readonly className?: string;
50
+ readonly mustType?: { readonly text: string; readonly typedId: string };
51
+ readonly onConfirm: () => void;
52
+ }) {
53
+ const [open, setOpen] = useState(false);
54
+ const [typed, setTyped] = useState('');
55
+
56
+ return (
57
+ <AlertDialog open={open} onOpenChange={setOpen}>
58
+ <AlertDialogTrigger
59
+ render={
60
+ <Button variant="destructive" size={size} className={className} disabled={disabled} />
61
+ }
62
+ >
63
+ {label}
64
+ </AlertDialogTrigger>
65
+ <AlertDialogContent>
66
+ <AlertDialogHeader>
67
+ <AlertDialogTitle className="wrap-anywhere">{title}</AlertDialogTitle>
68
+ <AlertDialogDescription className="wrap-anywhere">{description}</AlertDialogDescription>
69
+ </AlertDialogHeader>
70
+ {mustType !== undefined && (
71
+ <Field>
72
+ <FieldLabel htmlFor={mustType.typedId} className="wrap-anywhere">
73
+ To confirm, type &quot;{mustType.text}&quot;
74
+ </FieldLabel>
75
+ <Input
76
+ id={mustType.typedId}
77
+ autoComplete="off"
78
+ value={typed}
79
+ onChange={(event) => setTyped(event.target.value)}
80
+ />
81
+ </Field>
82
+ )}
83
+ <AlertDialogFooter>
84
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
85
+ <AlertDialogAction
86
+ variant="destructive"
87
+ className="max-w-full truncate"
88
+ disabled={mustType !== undefined && typed !== mustType.text}
89
+ onClick={() => {
90
+ setOpen(false);
91
+ onConfirm();
92
+ }}
93
+ >
94
+ {confirm ?? label}
95
+ </AlertDialogAction>
96
+ </AlertDialogFooter>
97
+ </AlertDialogContent>
98
+ </AlertDialog>
99
+ );
100
+ }
@@ -0,0 +1,24 @@
1
+ import { Badge } from './ui/badge.tsx';
2
+
3
+ const counted = new Intl.NumberFormat('en-US');
4
+
5
+ /**
6
+ * A count beside what it counts, as the Open and Closed tabs and the sidebar's items show it. A
7
+ * screen reader hears it after a comma: "Issues, 3". `more` says there are more than it counted,
8
+ * as `50+`.
9
+ */
10
+ export function Count({
11
+ value,
12
+ more = false,
13
+ }: {
14
+ readonly value: number;
15
+ readonly more?: boolean;
16
+ }) {
17
+ return (
18
+ <Badge variant="secondary" className="tabular-nums">
19
+ <span className="sr-only">, </span>
20
+ {counted.format(value)}
21
+ {more && '+'}
22
+ </Badge>
23
+ );
24
+ }
@@ -0,0 +1,38 @@
1
+ import { PlusIcon } from 'lucide-react';
2
+ import type { ComponentProps, ReactNode } from 'react';
3
+
4
+ import { HotkeyHint, hotkeys } from './hotkeys/hotkeys.tsx';
5
+ import { Button } from './ui/button.tsx';
6
+
7
+ /**
8
+ * A page's create action, such as New issue or Draft a new release: the one button every page's
9
+ * create action is, so each is the same height and padding, `lg`, the primary variant, with a
10
+ * leading `Plus` and then its text. With `hotkey`, `c` reaches it and its hint shows over its end.
11
+ * A link renders through `render`, such as `<Go href=… />`; a dialog's trigger renders it the same
12
+ * way. A button inside a dialog, such as Create branch, is a plain Button with its text alone.
13
+ */
14
+ export function CreateButton({
15
+ children,
16
+ hotkey = false,
17
+ render,
18
+ ...props
19
+ }: {
20
+ /** What it makes, such as "New issue". */
21
+ readonly children: ReactNode;
22
+ /** Whether `c`, the page's create key, reaches it. */
23
+ readonly hotkey?: boolean;
24
+ } & Omit<ComponentProps<typeof Button>, 'variant' | 'size' | 'children'>) {
25
+ return (
26
+ <Button
27
+ {...props}
28
+ size="lg"
29
+ nativeButton={render === undefined}
30
+ render={render}
31
+ data-hotkey={hotkey ? hotkeys.create : undefined}
32
+ >
33
+ <PlusIcon aria-hidden data-icon="inline-start" />
34
+ {children}
35
+ {hotkey && <HotkeyHint keys={hotkeys.create} />}
36
+ </Button>
37
+ );
38
+ }