ref0-git 0.0.0 → 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 +48 -6
  385. package/README.md +0 -5
@@ -0,0 +1,225 @@
1
+ /*
2
+ * The coloured file icons outside the file tree, in the file lists and the diff headers: the
3
+ * colours @pierre/trees 1.0.0 gives each icon in its own stylesheet, which the tree keeps in its
4
+ * shadow root. Apache-2.0, as THIRD_PARTY_NOTICES.md says. `light-dark()` follows the page's
5
+ * `color-scheme`, which the theme sets.
6
+ */
7
+ :root {
8
+ --file-icon-gray: light-dark(#84848a, #adadb1);
9
+ --file-icon-red: light-dark(#d52c36, #ff6762);
10
+ --file-icon-vermilion: light-dark(#ff8c5b, #d5512f);
11
+ --file-icon-orange: light-dark(#d47628, #ffa359);
12
+ --file-icon-yellow: light-dark(#d5a910, #ffd452);
13
+ --file-icon-green: light-dark(#199f43, #5ecc71);
14
+ --file-icon-teal: light-dark(#17a5af, #64d1db);
15
+ --file-icon-cyan: light-dark(#1ca1c7, #68cdf2);
16
+ --file-icon-blue: light-dark(#1a85d4, #69b1ff);
17
+ --file-icon-indigo: light-dark(#693acf, #9d6afb);
18
+ --file-icon-purple: light-dark(#a631be, #d568ea);
19
+ --file-icon-pink: light-dark(#d32a61, #ff678d);
20
+ --file-icon-mauve: light-dark(#594c5b, #79697b);
21
+ }
22
+
23
+ [data-file-icon] {
24
+ color: var(--muted-foreground);
25
+ }
26
+
27
+ [data-file-icon='default'] {
28
+ color: var(--file-icon-gray);
29
+ }
30
+
31
+ [data-file-icon='astro'] {
32
+ color: var(--file-icon-purple);
33
+ }
34
+
35
+ [data-file-icon='babel'] {
36
+ color: var(--file-icon-yellow);
37
+ }
38
+
39
+ [data-file-icon='bash'] {
40
+ color: var(--file-icon-green);
41
+ }
42
+
43
+ [data-file-icon='biome'] {
44
+ color: var(--file-icon-blue);
45
+ }
46
+
47
+ [data-file-icon='bootstrap'] {
48
+ color: var(--file-icon-indigo);
49
+ }
50
+
51
+ [data-file-icon='browserslist'] {
52
+ color: var(--file-icon-yellow);
53
+ }
54
+
55
+ [data-file-icon='bun'] {
56
+ color: var(--file-icon-mauve);
57
+ }
58
+
59
+ [data-file-icon='c'] {
60
+ color: var(--file-icon-blue);
61
+ }
62
+
63
+ [data-file-icon='cpp'] {
64
+ color: var(--file-icon-blue);
65
+ }
66
+
67
+ [data-file-icon='claude'] {
68
+ color: var(--file-icon-orange);
69
+ }
70
+
71
+ [data-file-icon='css'] {
72
+ color: var(--file-icon-indigo);
73
+ }
74
+
75
+ [data-file-icon='database'] {
76
+ color: var(--file-icon-purple);
77
+ }
78
+
79
+ [data-file-icon='docker'] {
80
+ color: var(--file-icon-blue);
81
+ }
82
+
83
+ [data-file-icon='eslint'] {
84
+ color: var(--file-icon-indigo);
85
+ }
86
+
87
+ [data-file-icon='go'] {
88
+ color: var(--file-icon-cyan);
89
+ }
90
+
91
+ [data-file-icon='graphql'] {
92
+ color: var(--file-icon-pink);
93
+ }
94
+
95
+ [data-file-icon='html'] {
96
+ color: var(--file-icon-orange);
97
+ }
98
+
99
+ [data-file-icon='image'] {
100
+ color: var(--file-icon-pink);
101
+ }
102
+
103
+ [data-file-icon='javascript'] {
104
+ color: var(--file-icon-yellow);
105
+ }
106
+
107
+ [data-file-icon='json'] {
108
+ color: var(--file-icon-orange);
109
+ }
110
+
111
+ [data-file-icon='markdown'] {
112
+ color: var(--file-icon-green);
113
+ }
114
+
115
+ [data-file-icon='mcp'] {
116
+ color: var(--file-icon-teal);
117
+ }
118
+
119
+ [data-file-icon='npm'] {
120
+ color: var(--file-icon-red);
121
+ }
122
+
123
+ [data-file-icon='postcss'] {
124
+ color: var(--file-icon-red);
125
+ }
126
+
127
+ [data-file-icon='prettier'] {
128
+ color: var(--file-icon-teal);
129
+ }
130
+
131
+ [data-file-icon='python'] {
132
+ color: var(--file-icon-blue);
133
+ }
134
+
135
+ [data-file-icon='react'] {
136
+ color: var(--file-icon-cyan);
137
+ }
138
+
139
+ [data-file-icon='ruby'] {
140
+ color: var(--file-icon-red);
141
+ }
142
+
143
+ [data-file-icon='rust'] {
144
+ color: var(--file-icon-orange);
145
+ }
146
+
147
+ [data-file-icon='sass'] {
148
+ color: var(--file-icon-pink);
149
+ }
150
+
151
+ [data-file-icon='svg'] {
152
+ color: var(--file-icon-orange);
153
+ }
154
+
155
+ [data-file-icon='svelte'] {
156
+ color: var(--file-icon-red);
157
+ }
158
+
159
+ [data-file-icon='svgo'] {
160
+ color: var(--file-icon-green);
161
+ }
162
+
163
+ [data-file-icon='swift'] {
164
+ color: var(--file-icon-orange);
165
+ }
166
+
167
+ [data-file-icon='table'] {
168
+ color: var(--file-icon-teal);
169
+ }
170
+
171
+ [data-file-icon='text'] {
172
+ color: var(--file-icon-gray);
173
+ }
174
+
175
+ [data-file-icon='tailwind'] {
176
+ color: var(--file-icon-cyan);
177
+ }
178
+
179
+ [data-file-icon='terraform'] {
180
+ color: var(--file-icon-indigo);
181
+ }
182
+
183
+ [data-file-icon='typescript'] {
184
+ color: var(--file-icon-blue);
185
+ }
186
+
187
+ [data-file-icon='vite'] {
188
+ color: var(--file-icon-purple);
189
+ }
190
+
191
+ [data-file-icon='vscode'] {
192
+ color: var(--file-icon-blue);
193
+ }
194
+
195
+ [data-file-icon='vue'] {
196
+ color: var(--file-icon-green);
197
+ }
198
+
199
+ [data-file-icon='wasm'] {
200
+ color: var(--file-icon-indigo);
201
+ }
202
+
203
+ [data-file-icon='webpack'] {
204
+ color: var(--file-icon-blue);
205
+ }
206
+
207
+ [data-file-icon='yml'] {
208
+ color: var(--file-icon-red);
209
+ }
210
+
211
+ [data-file-icon='zig'] {
212
+ color: var(--file-icon-orange);
213
+ }
214
+
215
+ [data-file-icon='zip'] {
216
+ color: var(--file-icon-orange);
217
+ }
218
+
219
+ [data-file-icon='git'] {
220
+ color: var(--file-icon-vermilion);
221
+ }
222
+
223
+ [data-file-icon='oxc'] {
224
+ color: var(--file-icon-cyan);
225
+ }
@@ -0,0 +1,138 @@
1
+ import { IconCodeFolder, IconFolder, IconLink } from '@pierre/icons';
2
+ import { createFileTreeIconResolver, getBuiltInSpriteSheet } from '@pierre/trees';
3
+ import { cn } from '#/lib/cn';
4
+ import {
5
+ Children,
6
+ isValidElement,
7
+ type ComponentProps,
8
+ type ReactElement,
9
+ type ReactNode,
10
+ } from 'react';
11
+
12
+ /**
13
+ * A file's icon, the one the file tree draws for it: `@pierre/trees`' coloured `complete` set,
14
+ * chosen by the file's name, so the tree, the file lists and the diff headers show a file alike.
15
+ * Folders, submodules and symlinks take `@pierre/icons`' glyphs, which the tree draws too.
16
+ */
17
+
18
+ /** The tree's icons: the `complete` set, coloured. The file tree takes the same. */
19
+ export const fileIcons = { set: 'complete', colored: true } as const;
20
+
21
+ const resolver = createFileTreeIconResolver(fileIcons);
22
+
23
+ /** The sprite's symbol for the file at `path`, and its type, which picks its colour. */
24
+ export const fileIconOf = (path: string) => {
25
+ const icon = resolver.resolveIcon('file-tree-icon-file', path);
26
+
27
+ return { symbol: icon.name, type: icon.token ?? 'default' };
28
+ };
29
+
30
+ /**
31
+ * The icons' symbols, as an SVG file of their own, which `/file-icons.svg` serves. The sheet's own
32
+ * root, drawn for HTML, has a bare attribute no XML file may hold, so its symbols go under a root
33
+ * of their own. The tree's copy stays in its shadow root.
34
+ */
35
+ export const fileIconSprite = () =>
36
+ getBuiltInSpriteSheet(fileIcons.set).replace(
37
+ /^\s*<svg[^>]*>/,
38
+ '<svg xmlns="http://www.w3.org/2000/svg">',
39
+ );
40
+
41
+ /** A string's FNV-1a hash, in base 36. */
42
+ const hashOf = (text: string) => {
43
+ let hash = 0x811c9dc5;
44
+
45
+ for (let index = 0; index < text.length; index += 1) {
46
+ hash = Math.imul(hash ^ text.charCodeAt(index), 0x01000193);
47
+ }
48
+
49
+ return (hash >>> 0).toString(36);
50
+ };
51
+
52
+ /**
53
+ * Where the icons' symbols are served, named by what they hold: the browser keeps the file for good,
54
+ * and a new `@pierre/trees` with other symbols names another.
55
+ */
56
+ export const fileIconsHref = `/file-icons.svg?v=${hashOf(fileIconSprite())}`;
57
+
58
+ /** The icon of the file at `path`, coloured for its type, as `file-icons.css` says. */
59
+ export function FileIcon({
60
+ path,
61
+ className,
62
+ ...props
63
+ }: { readonly path: string } & ComponentProps<'svg'>) {
64
+ const { symbol, type } = fileIconOf(path);
65
+
66
+ return (
67
+ <svg
68
+ aria-hidden
69
+ viewBox="0 0 16 16"
70
+ data-file-icon={type}
71
+ className={cn('size-4 shrink-0 fill-current', className)}
72
+ {...props}
73
+ >
74
+ <use href={`${fileIconsHref}#${symbol}`} />
75
+ </svg>
76
+ );
77
+ }
78
+
79
+ /** The glyphs' size and colour: 16px square, as a file's icon is, so names line up. */
80
+ const glyph = 'size-4 shrink-0 text-muted-foreground';
81
+
82
+ /** A folder's icon. */
83
+ export function FolderIcon({ className }: { readonly className?: string }) {
84
+ return <IconFolder aria-hidden className={cn(glyph, className)} />;
85
+ }
86
+
87
+ /** A submodule's icon: a folder of another repository's code. */
88
+ export function SubmoduleIcon({ className }: { readonly className?: string }) {
89
+ return <IconCodeFolder aria-hidden className={cn(glyph, className)} />;
90
+ }
91
+
92
+ /** A symlink's icon: a link to another path. */
93
+ export function SymlinkIcon({ className }: { readonly className?: string }) {
94
+ return <IconLink aria-hidden className={cn(glyph, className)} />;
95
+ }
96
+
97
+ /** The sprite symbols the file tree draws a folder's, a submodule's and a symlink's row with. */
98
+ export const glyphSymbols = {
99
+ folder: 'ref0-icon-folder',
100
+ submodule: 'ref0-icon-submodule',
101
+ symlink: 'ref0-icon-symlink',
102
+ } as const;
103
+
104
+ /** lucide's `Folder` and `FolderOpen` lines, which its React icons don't hand out as paths. */
105
+ const folderLines = {
106
+ closed:
107
+ 'M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z',
108
+ open: 'm6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2',
109
+ } as const;
110
+
111
+ /**
112
+ * A folder, closed and open, as one symbol: the tree gives a folder's row one icon whatever its
113
+ * state, so an open row sets `--ref0-folder-closed: none` and `--ref0-folder-open: inline`. A custom
114
+ * property reaches into the `use` that draws the symbol, as no selector does.
115
+ */
116
+ const folderSymbol = `<symbol id="${glyphSymbols.folder}" viewBox="0 0 24 24">${Object.entries(
117
+ folderLines,
118
+ )
119
+ .map(
120
+ ([state, d]) =>
121
+ `<path d="${d}" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:var(--ref0-folder-${state},${state === 'open' ? 'none' : 'inline'})"/>`,
122
+ )
123
+ .join('')}</symbol>`;
124
+
125
+ /** A glyph as a sprite symbol: each of `@pierre/icons`' is an `svg` of `path`s, drawn in `fill`. */
126
+ const symbolOf = (id: string, icon: ReactElement<{ viewBox: string; children: ReactNode }>) => {
127
+ const paths = Children.toArray(icon.props.children)
128
+ .flatMap((path) => (isValidElement<{ d: string }>(path) ? [`<path d="${path.props.d}"/>`] : []))
129
+ .join('');
130
+
131
+ return `<symbol id="${id}" viewBox="${icon.props.viewBox}">${paths}</symbol>`;
132
+ };
133
+
134
+ /** The folder's, the submodule's and the symlink's glyphs, as the sprite the tree adds to its own. */
135
+ export const glyphSprite = `<svg xmlns="http://www.w3.org/2000/svg" style="display:none">${folderSymbol}${symbolOf(
136
+ glyphSymbols.submodule,
137
+ IconCodeFolder({}),
138
+ )}${symbolOf(glyphSymbols.symlink, IconLink({}))}</svg>`;
@@ -0,0 +1,35 @@
1
+ import { ChevronDownIcon } from 'lucide-react';
2
+ import type { ReactNode } from 'react';
3
+
4
+ import { Button } from './ui/button.tsx';
5
+ import {
6
+ DropdownMenu,
7
+ DropdownMenuContent,
8
+ DropdownMenuGroup,
9
+ DropdownMenuLabel,
10
+ DropdownMenuTrigger,
11
+ } from './ui/dropdown-menu.tsx';
12
+
13
+ /** A short filter's menu, under its button, such as the order's: too few rows to search. */
14
+ export function Filter({
15
+ name,
16
+ children,
17
+ }: {
18
+ readonly name: string;
19
+ readonly children: ReactNode;
20
+ }) {
21
+ return (
22
+ <DropdownMenu>
23
+ <DropdownMenuTrigger render={<Button variant="ghost" size="sm" />}>
24
+ {name}
25
+ <ChevronDownIcon data-icon="inline-end" />
26
+ </DropdownMenuTrigger>
27
+ <DropdownMenuContent align="end" className="w-auto min-w-56">
28
+ <DropdownMenuGroup>
29
+ <DropdownMenuLabel>Filter by {name.toLowerCase()}</DropdownMenuLabel>
30
+ {children}
31
+ </DropdownMenuGroup>
32
+ </DropdownMenuContent>
33
+ </DropdownMenu>
34
+ );
35
+ }
@@ -0,0 +1,255 @@
1
+ import { cn } from '#/lib/cn';
2
+ import { useEffect, useSyncExternalStore, type ReactNode } from 'react';
3
+
4
+ import { Kbd, KbdGroup } from '../ui/kbd.tsx';
5
+
6
+ /**
7
+ * The app's keys, a small set of GitHub's. An element takes one by its `data-hotkey`: a key, or a
8
+ * sequence like `g i`. Pressing it focuses the element if it's a field, and clicks it otherwise.
9
+ * No key fires while someone types in a field, but ⌘↵ there clicks its box's `Mod+Enter` button,
10
+ * and ⌘K, or Ctrl+K off a Mac, opens the command palette from anywhere.
11
+ * Holding ⌘, or Ctrl off a Mac, shows each element's `HotkeyHint` at its end.
12
+ */
13
+ export const hotkeys = {
14
+ /** The page's search: a list's search box, or Go to file where there's none. */
15
+ search: '/',
16
+ /** Go to file, as GitHub's `t`. */
17
+ files: 't',
18
+ issues: 'g i',
19
+ pulls: 'g p',
20
+ /** The inbox, as GitHub's `g n` goes to its notifications. */
21
+ inbox: 'g n',
22
+ /** What the page makes: a repository, an issue, a pull request or a release. */
23
+ create: 'c',
24
+ /** The comment box's own button, from inside it. */
25
+ submit: 'Mod+Enter',
26
+ /** The command palette: `f` outside a field, and ⌘K, or Ctrl+K, inside one too. */
27
+ palette: 'f,Mod+K',
28
+ } as const;
29
+
30
+ /** How long the second key of a sequence may wait, as GitHub's `g` waits. */
31
+ const sequenceWait = 1500;
32
+
33
+ /** How long ⌘ or Ctrl is held, alone, before the hints show: a quick ⌘C shows none. */
34
+ const holdWait = 300;
35
+
36
+ /** The root's attribute while the hints show, which `HotkeyHint` waits for. */
37
+ const shownAttribute = 'data-hotkeys';
38
+
39
+ /** Whether this is a Mac, whose modifier is ⌘; elsewhere it's Ctrl. */
40
+ export const onMac = () => /Mac|iPhone|iPad/.test(navigator.platform);
41
+
42
+ /** Whether `target`, where a key landed, takes typing: a text field, a list box's or an editor. */
43
+ export const typesInto = (target: EventTarget | undefined) =>
44
+ target instanceof HTMLElement &&
45
+ (target.isContentEditable ||
46
+ target instanceof HTMLTextAreaElement ||
47
+ target instanceof HTMLSelectElement ||
48
+ (target instanceof HTMLInputElement &&
49
+ !['button', 'checkbox', 'radio', 'reset', 'submit'].includes(target.type)));
50
+
51
+ /** Whether `element` is out of reach: behind an open dialog, hidden, or disabled. */
52
+ const outOfReach = (element: Element) =>
53
+ element.closest('[inert], [hidden], [aria-hidden="true"]') !== null ||
54
+ element.matches(':disabled, [aria-disabled="true"]');
55
+
56
+ /**
57
+ * The element in reach under `within` that `keys` lead to: a field before anything else, so `/`
58
+ * reaches a page's search box before Go to file, then the first in the page's order.
59
+ */
60
+ const targetOf = (within: ParentNode, keys: string) => {
61
+ const reached = [...within.querySelectorAll<HTMLElement>('[data-hotkey]')].filter(
62
+ (element) =>
63
+ element.dataset['hotkey']?.split(',').some((each) => each.trim() === keys) === true &&
64
+ !outOfReach(element),
65
+ );
66
+
67
+ return reached.find(typesInto) ?? reached[0];
68
+ };
69
+
70
+ /** Focuses a field, and clicks anything else. */
71
+ const use = (element: HTMLElement) => {
72
+ if (typesInto(element)) element.focus();
73
+ else element.click();
74
+ };
75
+
76
+ /** Listens for the app's keys on the page, once, in the shell. */
77
+ export function Hotkeys() {
78
+ useEffect(() => {
79
+ const root = document.documentElement;
80
+ let pending: { readonly key: string; readonly at: number } | undefined;
81
+ let holding: ReturnType<typeof setTimeout> | undefined;
82
+
83
+ const hide = () => {
84
+ clearTimeout(holding);
85
+ holding = undefined;
86
+ root.removeAttribute(shownAttribute);
87
+ };
88
+
89
+ const down = (event: KeyboardEvent) => {
90
+ const modifier = onMac() ? 'Meta' : 'Control';
91
+
92
+ if (event.key === modifier && !event.repeat && !event.altKey && !event.shiftKey) {
93
+ holding = setTimeout(() => root.setAttribute(shownAttribute, 'shown'), holdWait);
94
+
95
+ return;
96
+ }
97
+
98
+ hide();
99
+
100
+ if (event.defaultPrevented || event.isComposing) return;
101
+ const [landed] = event.composedPath();
102
+
103
+ if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
104
+ const box = landed instanceof Element ? landed.closest('form, [data-hotkey-box]') : null;
105
+ const button =
106
+ typesInto(landed) && box !== null ? targetOf(box, hotkeys.submit) : undefined;
107
+ if (button === undefined) return;
108
+
109
+ event.preventDefault();
110
+ button.click();
111
+
112
+ return;
113
+ }
114
+
115
+ // The palette's chord, from a field too: a Mac's ⌘K, or Ctrl+K elsewhere, as GitHub's.
116
+ const chord = onMac() ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;
117
+
118
+ if (chord && !event.altKey && !event.shiftKey && event.key.toLowerCase() === 'k') {
119
+ const palette = targetOf(document, 'Mod+K');
120
+ if (palette === undefined) return;
121
+
122
+ event.preventDefault();
123
+ use(palette);
124
+
125
+ return;
126
+ }
127
+
128
+ if (event.metaKey || event.ctrlKey || event.altKey || typesInto(landed)) return;
129
+
130
+ // A key a sequence doesn't take counts alone, and may begin the next one.
131
+ const now = Date.now();
132
+ const sequence =
133
+ pending !== undefined && now - pending.at < sequenceWait
134
+ ? targetOf(document, `${pending.key} ${event.key}`)
135
+ : undefined;
136
+ pending = undefined;
137
+ const target = sequence ?? targetOf(document, event.key);
138
+
139
+ if (target !== undefined) {
140
+ event.preventDefault();
141
+ use(target);
142
+ } else if (event.key.length === 1) {
143
+ pending = { key: event.key, at: now };
144
+ }
145
+ };
146
+
147
+ window.addEventListener('keydown', down);
148
+ window.addEventListener('keyup', hide);
149
+ window.addEventListener('blur', hide);
150
+
151
+ return () => {
152
+ hide();
153
+ window.removeEventListener('keydown', down);
154
+ window.removeEventListener('keyup', hide);
155
+ window.removeEventListener('blur', hide);
156
+ };
157
+ }, []);
158
+
159
+ return null;
160
+ }
161
+
162
+ /** Whether this is a Mac, after the browser takes the page up; the server draws Ctrl. */
163
+ const useOnMac = () =>
164
+ useSyncExternalStore(
165
+ () => () => {},
166
+ onMac,
167
+ () => false,
168
+ );
169
+
170
+ /** What a key's cap says: ⌘ or Ctrl for the modifier, ↵ for Enter, and other keys as they are. */
171
+ const capOf = (key: string, mac: boolean) => {
172
+ if (key === 'Mod') return mac ? '⌘' : 'Ctrl';
173
+
174
+ if (key === 'Enter') return '↵';
175
+
176
+ return key.toUpperCase();
177
+ };
178
+
179
+ /** The caps of `keys`: a sequence's keys apart, a chord's together, ⌘↵ on a Mac and Ctrl+↵ elsewhere. */
180
+ export function Keys({
181
+ keys,
182
+ className,
183
+ 'data-hint': hint,
184
+ }: {
185
+ readonly keys: string;
186
+ readonly className?: string;
187
+ /** `over` on a hint laid over its control's end, which makes the control its frame. */
188
+ readonly 'data-hint'?: 'over';
189
+ }) {
190
+ const mac = useOnMac();
191
+ const caps = keys.includes('+')
192
+ ? [
193
+ keys
194
+ .split('+')
195
+ .map((key) => capOf(key, mac))
196
+ .join(mac ? '' : '+'),
197
+ ]
198
+ : keys.split(' ').map((key) => capOf(key, mac));
199
+
200
+ return (
201
+ <KbdGroup aria-hidden data-hint={hint} className={className}>
202
+ {caps.map((cap, index) => (
203
+ // The cap is drawn, not written, so the element's own text, which names it, stays its own.
204
+ <Kbd key={`${index}:${cap}`} data-cap={cap} className="after:content-[attr(data-cap)]" />
205
+ ))}
206
+ </KbdGroup>
207
+ );
208
+ }
209
+
210
+ /**
211
+ * The `keys` that reach a control, shown while ⌘, or Ctrl off a Mac, is held. With `children`,
212
+ * such as a count, the keys show in the children's place: both share one grid cell, as wide as the
213
+ * wider, so showing the keys moves nothing. With none, the hint takes no room at all: the keys are
214
+ * laid over the control's end, inside its border, on the control's own background, and the label
215
+ * stays where it is, so a hinted button is exactly as wide as the same button without its hint.
216
+ * They swap at once, in every motion setting: a key a person holds many times a day shouldn't wait
217
+ * on an animation.
218
+ */
219
+ export function HotkeyHint({
220
+ keys,
221
+ children,
222
+ className,
223
+ }: {
224
+ readonly keys: string;
225
+ readonly children?: ReactNode;
226
+ readonly className?: string;
227
+ }) {
228
+ if (children === undefined || children === false) {
229
+ return (
230
+ <Keys
231
+ keys={keys}
232
+ data-hint="over"
233
+ className={cn(
234
+ 'pointer-events-none absolute inset-y-0 end-1.5 my-auto hidden h-fit rounded-sm bg-inherit in-data-[hotkeys=shown]:flex *:bg-current/10 *:text-inherit',
235
+ className,
236
+ )}
237
+ />
238
+ );
239
+ }
240
+
241
+ return (
242
+ <span
243
+ className={cn(
244
+ 'inline-grid shrink-0 items-center justify-items-end *:col-start-1 *:row-start-1',
245
+ className,
246
+ )}
247
+ >
248
+ <span className="inline-flex in-data-[hotkeys=shown]:invisible">{children}</span>
249
+ <Keys
250
+ keys={keys}
251
+ className="invisible in-data-[hotkeys=shown]:visible *:bg-current/10 *:text-inherit"
252
+ />
253
+ </span>
254
+ );
255
+ }