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.
- package/app/apps/github/.dev.vars.example +6 -0
- package/app/apps/github/README.md +70 -0
- package/app/apps/github/THIRD_PARTY_NOTICES.md +214 -0
- package/app/apps/github/components.json +25 -0
- package/app/apps/github/generated/git-rest.ts +10444 -0
- package/app/apps/github/generated/routeTree.gen.ts +1242 -0
- package/app/apps/github/migrations/postgres/0001_auth.sql +46 -0
- package/app/apps/github/migrations/sql/0001_auth.sql +19 -0
- package/app/apps/github/migrations/sql/0002_passkeys.sql +9 -0
- package/app/apps/github/migrations/sql/0003_orgs.sql +22 -0
- package/app/apps/github/migrations/sql/0004_avatars.sql +6 -0
- package/app/apps/github/package.json +80 -0
- package/app/apps/github/src/branches/branch-list.tsx +385 -0
- package/app/apps/github/src/branches/branches.ts +55 -0
- package/app/apps/github/src/clients/allowed.ts +213 -0
- package/app/apps/github/src/clients/at-most.ts +17 -0
- package/app/apps/github/src/clients/avatars.ts +410 -0
- package/app/apps/github/src/clients/cached.ts +65 -0
- package/app/apps/github/src/clients/calls.ts +160 -0
- package/app/apps/github/src/clients/clients.ts +82 -0
- package/app/apps/github/src/clients/graphql.ts +50 -0
- package/app/apps/github/src/clients/host-answer.ts +28 -0
- package/app/apps/github/src/clients/host-calls.ts +382 -0
- package/app/apps/github/src/clients/icon-bytes.ts +203 -0
- package/app/apps/github/src/clients/proxy.ts +59 -0
- package/app/apps/github/src/clients/session-ended.ts +18 -0
- package/app/apps/github/src/clients/transfers.ts +212 -0
- package/app/apps/github/src/code/breadcrumbs.tsx +50 -0
- package/app/apps/github/src/code/code-page.tsx +147 -0
- package/app/apps/github/src/code/code-tree.tsx +338 -0
- package/app/apps/github/src/code/controls.tsx +230 -0
- package/app/apps/github/src/code/file-view.tsx +450 -0
- package/app/apps/github/src/code/files.ts +332 -0
- package/app/apps/github/src/code/folder-list.tsx +122 -0
- package/app/apps/github/src/code/go-to-file.tsx +131 -0
- package/app/apps/github/src/code/highlighted.tsx +58 -0
- package/app/apps/github/src/code/lines.ts +46 -0
- package/app/apps/github/src/code/load.ts +147 -0
- package/app/apps/github/src/code/markdown-files.ts +58 -0
- package/app/apps/github/src/code/places.ts +88 -0
- package/app/apps/github/src/code/ref-pages.ts +179 -0
- package/app/apps/github/src/code/ref-switcher.tsx +203 -0
- package/app/apps/github/src/code/refs.ts +142 -0
- package/app/apps/github/src/code/repo-home.tsx +240 -0
- package/app/apps/github/src/code/repo.ts +105 -0
- package/app/apps/github/src/code/saved-reads.ts +199 -0
- package/app/apps/github/src/code/saved.ts +110 -0
- package/app/apps/github/src/code/tree-fold.ts +186 -0
- package/app/apps/github/src/code/trees.ts +136 -0
- package/app/apps/github/src/components/avatar-picture.ts +53 -0
- package/app/apps/github/src/components/avatar-url.ts +16 -0
- package/app/apps/github/src/components/confirm-action.tsx +100 -0
- package/app/apps/github/src/components/count.tsx +24 -0
- package/app/apps/github/src/components/create-button.tsx +38 -0
- package/app/apps/github/src/components/file-icons/file-icons.css +225 -0
- package/app/apps/github/src/components/file-icons/file-icons.tsx +138 -0
- package/app/apps/github/src/components/filter.tsx +35 -0
- package/app/apps/github/src/components/hotkeys/hotkeys.tsx +255 -0
- package/app/apps/github/src/components/item-list.tsx +65 -0
- package/app/apps/github/src/components/language-dot.tsx +29 -0
- package/app/apps/github/src/components/list-toolbar.tsx +82 -0
- package/app/apps/github/src/components/markdown/editor.tsx +57 -0
- package/app/apps/github/src/components/markdown/markdown.css +177 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +82 -0
- package/app/apps/github/src/components/owner-card.tsx +196 -0
- package/app/apps/github/src/components/pull-status.tsx +34 -0
- package/app/apps/github/src/components/recent.ts +41 -0
- package/app/apps/github/src/components/relative-time.tsx +78 -0
- package/app/apps/github/src/components/repos/icon-hashes.ts +91 -0
- package/app/apps/github/src/components/repos/new-repo-form.tsx +196 -0
- package/app/apps/github/src/components/repos/repo-icon.tsx +47 -0
- package/app/apps/github/src/components/repos/repo-list.tsx +528 -0
- package/app/apps/github/src/components/repos/your-repos.tsx +124 -0
- package/app/apps/github/src/components/review-state.tsx +75 -0
- package/app/apps/github/src/components/route-dialog.tsx +137 -0
- package/app/apps/github/src/components/save-button.tsx +58 -0
- package/app/apps/github/src/components/shell/app-shell.tsx +164 -0
- package/app/apps/github/src/components/shell/create-org-dialog.tsx +118 -0
- package/app/apps/github/src/components/shell/create-row.tsx +49 -0
- package/app/apps/github/src/components/shell/link-menu.tsx +94 -0
- package/app/apps/github/src/components/shell/nav-user.tsx +97 -0
- package/app/apps/github/src/components/shell/owner-repos.tsx +247 -0
- package/app/apps/github/src/components/shell/owner-switcher.tsx +104 -0
- package/app/apps/github/src/components/shell/repo-switcher.tsx +179 -0
- package/app/apps/github/src/components/shell/sections.ts +31 -0
- package/app/apps/github/src/components/shell/submenu-chevron.ts +147 -0
- package/app/apps/github/src/components/signin/device-card.tsx +139 -0
- package/app/apps/github/src/components/signin/login-form.tsx +88 -0
- package/app/apps/github/src/components/signin/signin-page.tsx +33 -0
- package/app/apps/github/src/components/signin/signup-form.tsx +106 -0
- package/app/apps/github/src/components/states/live-status.tsx +42 -0
- package/app/apps/github/src/components/states/states.tsx +126 -0
- package/app/apps/github/src/components/tab-indicator.tsx +143 -0
- package/app/apps/github/src/components/theme-choice.tsx +108 -0
- package/app/apps/github/src/components/theme-provider.tsx +126 -0
- package/app/apps/github/src/components/tones.ts +23 -0
- package/app/apps/github/src/components/ui/alert-dialog.tsx +187 -0
- package/app/apps/github/src/components/ui/alert.tsx +78 -0
- package/app/apps/github/src/components/ui/avatar.tsx +106 -0
- package/app/apps/github/src/components/ui/badge.tsx +51 -0
- package/app/apps/github/src/components/ui/breadcrumb.tsx +124 -0
- package/app/apps/github/src/components/ui/button-group.tsx +87 -0
- package/app/apps/github/src/components/ui/button.tsx +61 -0
- package/app/apps/github/src/components/ui/calendar.tsx +221 -0
- package/app/apps/github/src/components/ui/card.tsx +102 -0
- package/app/apps/github/src/components/ui/checkbox.tsx +26 -0
- package/app/apps/github/src/components/ui/collapsible.tsx +19 -0
- package/app/apps/github/src/components/ui/combobox.tsx +304 -0
- package/app/apps/github/src/components/ui/command.tsx +208 -0
- package/app/apps/github/src/components/ui/dialog.tsx +156 -0
- package/app/apps/github/src/components/ui/dropdown-menu.tsx +290 -0
- package/app/apps/github/src/components/ui/empty.tsx +100 -0
- package/app/apps/github/src/components/ui/field.tsx +236 -0
- package/app/apps/github/src/components/ui/hover-card.tsx +48 -0
- package/app/apps/github/src/components/ui/input-group.tsx +163 -0
- package/app/apps/github/src/components/ui/input.tsx +19 -0
- package/app/apps/github/src/components/ui/item.tsx +201 -0
- package/app/apps/github/src/components/ui/kbd.tsx +27 -0
- package/app/apps/github/src/components/ui/label.tsx +33 -0
- package/app/apps/github/src/components/ui/popover.tsx +87 -0
- package/app/apps/github/src/components/ui/radio-group.tsx +35 -0
- package/app/apps/github/src/components/ui/select.tsx +198 -0
- package/app/apps/github/src/components/ui/separator.tsx +22 -0
- package/app/apps/github/src/components/ui/sheet.tsx +138 -0
- package/app/apps/github/src/components/ui/sidebar.tsx +724 -0
- package/app/apps/github/src/components/ui/skeleton.tsx +13 -0
- package/app/apps/github/src/components/ui/sonner.tsx +47 -0
- package/app/apps/github/src/components/ui/styles.css +242 -0
- package/app/apps/github/src/components/ui/table.tsx +113 -0
- package/app/apps/github/src/components/ui/tabs.tsx +79 -0
- package/app/apps/github/src/components/ui/textarea.tsx +17 -0
- package/app/apps/github/src/components/ui/title.ts +6 -0
- package/app/apps/github/src/components/ui/toggle-group.tsx +89 -0
- package/app/apps/github/src/components/ui/toggle.tsx +42 -0
- package/app/apps/github/src/components/ui/tooltip.tsx +63 -0
- package/app/apps/github/src/components/user-avatar.tsx +145 -0
- package/app/apps/github/src/components/view-tabs.tsx +42 -0
- package/app/apps/github/src/context/context.ts +133 -0
- package/app/apps/github/src/diffs/blobs.ts +94 -0
- package/app/apps/github/src/diffs/diff-view.tsx +155 -0
- package/app/apps/github/src/diffs/files.ts +121 -0
- package/app/apps/github/src/diffs/hunks.tsx +454 -0
- package/app/apps/github/src/diffs/patch.ts +131 -0
- package/app/apps/github/src/diffs/rows.ts +137 -0
- package/app/apps/github/src/history/commit-diff.ts +54 -0
- package/app/apps/github/src/history/commit-list.tsx +207 -0
- package/app/apps/github/src/history/commit-page.tsx +147 -0
- package/app/apps/github/src/history/history.ts +129 -0
- package/app/apps/github/src/hooks/allowed.ts +31 -0
- package/app/apps/github/src/hooks/answers.ts +65 -0
- package/app/apps/github/src/hooks/avatars.ts +54 -0
- package/app/apps/github/src/hooks/draft.ts +38 -0
- package/app/apps/github/src/hooks/open-counts.ts +127 -0
- package/app/apps/github/src/hooks/profiles.ts +120 -0
- package/app/apps/github/src/hooks/repos.ts +440 -0
- package/app/apps/github/src/hooks/use-mobile.ts +19 -0
- package/app/apps/github/src/hooks/viewer.ts +39 -0
- package/app/apps/github/src/inbox/count.ts +70 -0
- package/app/apps/github/src/inbox/inbox-item.tsx +66 -0
- package/app/apps/github/src/inbox/inbox-page.tsx +572 -0
- package/app/apps/github/src/inbox/marks.ts +130 -0
- package/app/apps/github/src/inbox/release-tags.ts +65 -0
- package/app/apps/github/src/inbox/search.ts +97 -0
- package/app/apps/github/src/inbox/subjects.ts +184 -0
- package/app/apps/github/src/inbox/subscription-controls.tsx +184 -0
- package/app/apps/github/src/inbox/subscriptions.ts +189 -0
- package/app/apps/github/src/inbox/threads.ts +198 -0
- package/app/apps/github/src/issues/changes.ts +332 -0
- package/app/apps/github/src/issues/counts.ts +62 -0
- package/app/apps/github/src/issues/issue-list.tsx +682 -0
- package/app/apps/github/src/issues/issue-page.tsx +533 -0
- package/app/apps/github/src/issues/issues.ts +566 -0
- package/app/apps/github/src/issues/label-dialog.tsx +310 -0
- package/app/apps/github/src/issues/labels-page.tsx +119 -0
- package/app/apps/github/src/issues/new-issue.tsx +79 -0
- package/app/apps/github/src/issues/parts.tsx +71 -0
- package/app/apps/github/src/issues/picker.tsx +298 -0
- package/app/apps/github/src/issues/search.ts +238 -0
- package/app/apps/github/src/issues/sidebar.tsx +236 -0
- package/app/apps/github/src/lib/cn.ts +8 -0
- package/app/apps/github/src/lib/highlighting.ts +13 -0
- package/app/apps/github/src/live/follow.ts +129 -0
- package/app/apps/github/src/live/sse.ts +74 -0
- package/app/apps/github/src/live/use-follow.ts +37 -0
- package/app/apps/github/src/markdown/README.md +53 -0
- package/app/apps/github/src/markdown/allowed-html.ts +69 -0
- package/app/apps/github/src/markdown/context.ts +206 -0
- package/app/apps/github/src/markdown/images.ts +81 -0
- package/app/apps/github/src/markdown/lookup.ts +127 -0
- package/app/apps/github/src/markdown/patches.ts +299 -0
- package/app/apps/github/src/markdown/query.ts +25 -0
- package/app/apps/github/src/markdown/references.ts +158 -0
- package/app/apps/github/src/markdown/render.ts +103 -0
- package/app/apps/github/src/names/owners.ts +51 -0
- package/app/apps/github/src/names/repos.ts +24 -0
- package/app/apps/github/src/palette/palette.tsx +562 -0
- package/app/apps/github/src/palette/recent.ts +116 -0
- package/app/apps/github/src/palette/rows.tsx +487 -0
- package/app/apps/github/src/palette/server.ts +107 -0
- package/app/apps/github/src/palette/targets.ts +306 -0
- package/app/apps/github/src/policy.ts +606 -0
- package/app/apps/github/src/private-repos.ts +47 -0
- package/app/apps/github/src/pulls/compare-page.tsx +342 -0
- package/app/apps/github/src/pulls/files-tab.tsx +776 -0
- package/app/apps/github/src/pulls/live.ts +124 -0
- package/app/apps/github/src/pulls/merge-box.tsx +367 -0
- package/app/apps/github/src/pulls/merge-button.ts +86 -0
- package/app/apps/github/src/pulls/pull-list.tsx +235 -0
- package/app/apps/github/src/pulls/pull-page.tsx +474 -0
- package/app/apps/github/src/pulls/pull.ts +468 -0
- package/app/apps/github/src/pulls/pulls.ts +318 -0
- package/app/apps/github/src/pulls/review.ts +350 -0
- package/app/apps/github/src/pulls/search.ts +130 -0
- package/app/apps/github/src/queue/queue-page.tsx +405 -0
- package/app/apps/github/src/queue/queue.ts +231 -0
- package/app/apps/github/src/releases/latest-release.tsx +55 -0
- package/app/apps/github/src/releases/overview.tsx +30 -0
- package/app/apps/github/src/releases/release-form.tsx +353 -0
- package/app/apps/github/src/releases/release-list.tsx +173 -0
- package/app/apps/github/src/releases/release-view.tsx +183 -0
- package/app/apps/github/src/releases/releases.ts +308 -0
- package/app/apps/github/src/releases/tag-list.tsx +134 -0
- package/app/apps/github/src/router.tsx +46 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +33 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/_code.tsx +11 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases.tsx +23 -0
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +39 -0
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +34 -0
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +42 -0
- package/app/apps/github/src/routes/$owner/$repo/compare/$.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +24 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +50 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +53 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +43 -0
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/checks.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/commits.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/files.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +52 -0
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +48 -0
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +58 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +40 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +35 -0
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +102 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/access.tsx +9 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +16 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/new.tsx +25 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +17 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/route.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/rules.tsx +12 -0
- package/app/apps/github/src/routes/$owner/$repo/tokens.tsx +16 -0
- package/app/apps/github/src/routes/$owner/index.tsx +45 -0
- package/app/apps/github/src/routes/-nav.tsx +293 -0
- package/app/apps/github/src/routes/-root-testing.ts +107 -0
- package/app/apps/github/src/routes/__root.tsx +225 -0
- package/app/apps/github/src/routes/api.auth.$.ts +18 -0
- package/app/apps/github/src/routes/downloads/$owner/$repo/$asset.tsx +10 -0
- package/app/apps/github/src/routes/file-icons[.]svg.ts +21 -0
- package/app/apps/github/src/routes/icons/$owner/$repo.tsx +14 -0
- package/app/apps/github/src/routes/icons/$owner/index.tsx +14 -0
- package/app/apps/github/src/routes/icons/index.tsx +12 -0
- package/app/apps/github/src/routes/index.tsx +48 -0
- package/app/apps/github/src/routes/login.tsx +24 -0
- package/app/apps/github/src/routes/login_.code.tsx +31 -0
- package/app/apps/github/src/routes/new.tsx +91 -0
- package/app/apps/github/src/routes/notifications.tsx +20 -0
- package/app/apps/github/src/routes/orgs/$owner/issues.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/releases.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +25 -0
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +30 -0
- package/app/apps/github/src/routes/orgs/$owner/tokens.tsx +15 -0
- package/app/apps/github/src/routes/settings.tsx +54 -0
- package/app/apps/github/src/routes/signup.tsx +24 -0
- package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +10 -0
- package/app/apps/github/src/seed/acme.ts +498 -0
- package/app/apps/github/src/seed/licenses.ts +114 -0
- package/app/apps/github/src/seed/seed.ts +528 -0
- package/app/apps/github/src/server.ts +97 -0
- package/app/apps/github/src/settings/account-avatar.tsx +43 -0
- package/app/apps/github/src/settings/avatar-section.tsx +140 -0
- package/app/apps/github/src/settings/avatar.ts +58 -0
- package/app/apps/github/src/settings/general-settings.tsx +439 -0
- package/app/apps/github/src/settings/general.ts +73 -0
- package/app/apps/github/src/settings/hook-form.tsx +195 -0
- package/app/apps/github/src/settings/hook-list.tsx +166 -0
- package/app/apps/github/src/settings/hooks.ts +87 -0
- package/app/apps/github/src/settings/org-settings.tsx +228 -0
- package/app/apps/github/src/settings/orgs.ts +116 -0
- package/app/apps/github/src/settings/rule-list.tsx +72 -0
- package/app/apps/github/src/settings/rules.ts +27 -0
- package/app/apps/github/src/settings/settings-layout.tsx +114 -0
- package/app/apps/github/src/signin/approval.ts +186 -0
- package/app/apps/github/src/signin/auth-client.ts +127 -0
- package/app/apps/github/src/signin/auth.ts +753 -0
- package/app/apps/github/src/signin/avatars.ts +126 -0
- package/app/apps/github/src/signin/client-ip.ts +39 -0
- package/app/apps/github/src/signin/credentials.ts +26 -0
- package/app/apps/github/src/signin/device-code.ts +95 -0
- package/app/apps/github/src/signin/device-prompt.ts +125 -0
- package/app/apps/github/src/signin/errors.ts +135 -0
- package/app/apps/github/src/signin/host-session.ts +68 -0
- package/app/apps/github/src/signin/orgs.ts +283 -0
- package/app/apps/github/src/signin/owner-names.ts +183 -0
- package/app/apps/github/src/signin/person-lock.ts +104 -0
- package/app/apps/github/src/signin/seal.ts +88 -0
- package/app/apps/github/src/signin/seed-people.ts +92 -0
- package/app/apps/github/src/signin/session.ts +48 -0
- package/app/apps/github/src/signin/unborn.ts +110 -0
- package/app/apps/github/src/signin/viewer-orgs.ts +47 -0
- package/app/apps/github/src/signin/viewer.ts +74 -0
- package/app/apps/github/src/signin/with-headers.ts +14 -0
- package/app/apps/github/src/tokens/tokens-page.tsx +529 -0
- package/app/apps/github/src/tokens/tokens.ts +54 -0
- package/app/apps/github/tsconfig.json +25 -0
- package/app/apps/github/tsconfig.worker.json +24 -0
- package/app/apps/github/vite.config.ts +21 -0
- package/app/pnpm-workspace.yaml +216 -0
- package/app/tsconfig.base.json +127 -0
- package/dist/LICENSE +202 -0
- package/dist/cli/child.mjs +42 -0
- package/dist/cli/commands.mjs +23 -0
- package/dist/cli/credentials.mjs +84 -0
- package/dist/cli/documents.mjs +214 -0
- package/dist/cli/events.mjs +55 -0
- package/dist/cli/failure.mjs +105 -0
- package/dist/cli/folders.mjs +32 -0
- package/dist/cli/git-remote-ref0.d.mts +1 -0
- package/dist/cli/git-remote-ref0.mjs +29 -0
- package/dist/cli/git.mjs +69 -0
- package/dist/cli/helpers.mjs +184 -0
- package/dist/cli/hosts.mjs +127 -0
- package/dist/cli/node.mjs +15 -0
- package/dist/cli/output.mjs +135 -0
- package/dist/cli/prompt.mjs +35 -0
- package/dist/cli/queue.mjs +215 -0
- package/dist/cli/ref0-git.d.mts +1 -0
- package/dist/cli/ref0-git.mjs +144 -0
- package/dist/cli/repos.mjs +162 -0
- package/dist/cli/resources.mjs +131 -0
- package/dist/cli/run-end.mjs +57 -0
- package/dist/cli/runtime.mjs +50 -0
- package/dist/cli/setup.mjs +1410 -0
- package/dist/cli/sign-in.mjs +162 -0
- package/dist/cli/sign-ins.mjs +136 -0
- package/dist/cli/sqlite.mjs +28 -0
- package/dist/cli/tokens.mjs +141 -0
- package/dist/cli/vendor.mjs +123 -0
- package/dist/init/app.mjs +231 -0
- package/dist/init/astro.mjs +49 -0
- package/dist/init/choices.mjs +497 -0
- package/dist/init/cloudflare.mjs +324 -0
- package/dist/init/create.mjs +151 -0
- package/dist/init/detect.mjs +297 -0
- package/dist/init/files.mjs +80 -0
- package/dist/init/frameworks.mjs +248 -0
- package/dist/init/git-module.mjs +49 -0
- package/dist/init/github-routes.mjs +66 -0
- package/dist/init/jsonc.mjs +143 -0
- package/dist/init/metadata.mjs +48 -0
- package/dist/init/mounts.mjs +109 -0
- package/dist/init/next.mjs +203 -0
- package/dist/init/node-app.mjs +189 -0
- package/dist/init/node.mjs +460 -0
- package/dist/init/nuxt.mjs +115 -0
- package/dist/init/output.mjs +21 -0
- package/dist/init/plan.mjs +82 -0
- package/dist/init/range-major.mjs +257 -0
- package/dist/init/react-router.mjs +59 -0
- package/dist/init/routes.mjs +148 -0
- package/dist/init/shell.mjs +4 -0
- package/dist/init/stores.mjs +51 -0
- package/dist/init/sveltekit.mjs +139 -0
- package/dist/init/template.mjs +142 -0
- package/dist/init/templates.mjs +343 -0
- package/dist/init/vercel.mjs +384 -0
- package/dist/init/versions.mjs +32 -0
- package/dist/init/workspace.mjs +20 -0
- package/package.json +48 -6
- package/README.md +0 -5
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
|
|
3
|
+
import { cached } from '../clients/cached.ts';
|
|
4
|
+
|
|
5
|
+
import { fileAt, readmeAt, readmeNow, type FileAt } from './files.ts';
|
|
6
|
+
import { readmeIn, renderAhead } from './markdown-files.ts';
|
|
7
|
+
import { isOid, parentOf, type At, type RepoPlace } from './places.ts';
|
|
8
|
+
import { atOf, headCommit, type CommitRow } from './refs.ts';
|
|
9
|
+
import { repoAt, type Repo } from './repo.ts';
|
|
10
|
+
import { restore } from './saved.ts';
|
|
11
|
+
import { readFolder, walk, type Entry, type Folder } from './trees.ts';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* What a folder's or a file's page loads before it draws: its ref, the commit that ref names, and
|
|
15
|
+
* the folders down its path, a call each. A file's page reads the file too, pinned to that commit.
|
|
16
|
+
* The page draws what its loader read, so a ref past `refFresh` is asked again before it draws,
|
|
17
|
+
* as a push may have moved it; the folders and files at a commit never change, and draw at once.
|
|
18
|
+
*/
|
|
19
|
+
export interface CodeLoad {
|
|
20
|
+
readonly at: At;
|
|
21
|
+
readonly head: CommitRow;
|
|
22
|
+
readonly walked: readonly Folder[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The file at `path` in the commit `commit`, from memory, or saved when this page saves reads. */
|
|
26
|
+
const readFile = async (client: QueryClient, place: RepoPlace, commit: string, path: string) => {
|
|
27
|
+
const options = fileAt(place, commit, path);
|
|
28
|
+
await restore(client, place, options.queryKey, (saved) => {
|
|
29
|
+
if ('shown' in saved) client.setQueryData(options.queryKey, saved);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return cached(client, options);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* `splat`'s ref, and the commit it names now. The head of the branch the splat's first segment
|
|
37
|
+
* names is asked beside the ref's checks, since that's the ref most pages name, and it's drawn
|
|
38
|
+
* only once they name that branch. A ref with a slash, or a tag, asks for its own head after them.
|
|
39
|
+
*/
|
|
40
|
+
const refAndHead = async (client: QueryClient, place: RepoPlace, splat: string) => {
|
|
41
|
+
const first = splat.split('/')[0] ?? '';
|
|
42
|
+
|
|
43
|
+
if (first !== '' && !isOid(first)) {
|
|
44
|
+
// Its answer, or its failure, waits under that branch's key for the head asked below.
|
|
45
|
+
void client.query(headCommit(place, { name: first, kind: 'branch' })).catch(() => undefined);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const at = await atOf(client, place, splat);
|
|
49
|
+
const head = at === undefined ? null : await client.query(headCommit(place, at.ref));
|
|
50
|
+
|
|
51
|
+
return { at, head };
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** A folder's page, or `undefined` where the URL names no folder. */
|
|
55
|
+
export const loadFolder = async (
|
|
56
|
+
client: QueryClient,
|
|
57
|
+
place: RepoPlace,
|
|
58
|
+
splat: string,
|
|
59
|
+
): Promise<CodeLoad | undefined> => {
|
|
60
|
+
const { at, head } = await refAndHead(client, place, splat);
|
|
61
|
+
if (at === undefined || head === null) return undefined;
|
|
62
|
+
|
|
63
|
+
const walked = await walk(client, place, head.tree, at.path);
|
|
64
|
+
|
|
65
|
+
return walked === undefined ? undefined : { at, head, walked };
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/** What a repository's home loads: a repository with no commits has no root and no README. */
|
|
69
|
+
export interface HomeLoad {
|
|
70
|
+
readonly repo: Repo;
|
|
71
|
+
readonly at: At;
|
|
72
|
+
readonly head: CommitRow | null;
|
|
73
|
+
readonly root: Folder | null;
|
|
74
|
+
readonly readme: FileAt | null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The README `named` at `commit`, as a file's page reads it: from `early`, the drop-in's README at
|
|
79
|
+
* the default branch, when it's that same file, so it costs no read after the root's.
|
|
80
|
+
*/
|
|
81
|
+
const readReadme = async (
|
|
82
|
+
client: QueryClient,
|
|
83
|
+
place: RepoPlace,
|
|
84
|
+
commit: string,
|
|
85
|
+
named: Entry,
|
|
86
|
+
early: Promise<Parameters<typeof readmeAt>[3]>,
|
|
87
|
+
) => {
|
|
88
|
+
const options = fileAt(place, commit, named.path);
|
|
89
|
+
|
|
90
|
+
if (client.getQueryData(options.queryKey) === undefined) {
|
|
91
|
+
const file = await readmeAt(place, commit, named, await early);
|
|
92
|
+
if (file !== undefined) client.setQueryData(options.queryKey, file);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return readFile(client, place, commit, named.path);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A repository's home at its default branch, or `undefined` where no repository is: its root, and
|
|
100
|
+
* the README the root lists, read as its page reads a file and rendered ahead. The drop-in's
|
|
101
|
+
* README is asked beside the repo, its head and its root, so the home waits on one read fewer.
|
|
102
|
+
*/
|
|
103
|
+
export const loadHome = async (
|
|
104
|
+
client: QueryClient,
|
|
105
|
+
place: RepoPlace,
|
|
106
|
+
): Promise<HomeLoad | undefined> => {
|
|
107
|
+
// A README the drop-in can't read is read at the commit, as the root names it.
|
|
108
|
+
const early = client.query(readmeNow(place)).catch(() => null);
|
|
109
|
+
const repo = await cached(client, repoAt(place));
|
|
110
|
+
if (repo === null) return undefined;
|
|
111
|
+
|
|
112
|
+
const at = { ...place, ref: { name: repo.defaultBranch, kind: 'branch' as const }, path: '' };
|
|
113
|
+
const head = await client.query(headCommit(place, at.ref));
|
|
114
|
+
if (head === null) return { repo, at, head, root: null, readme: null };
|
|
115
|
+
|
|
116
|
+
const root = await readFolder(client, place, head.tree, '');
|
|
117
|
+
const named = readmeIn(root);
|
|
118
|
+
const readme =
|
|
119
|
+
named === undefined ? null : await readReadme(client, place, head.sha, named, early);
|
|
120
|
+
if (readme !== null) await renderAhead(client, at, readme);
|
|
121
|
+
|
|
122
|
+
return { repo, at, head, root, readme };
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* A file's page, or `undefined` where the URL names no file: a Markdown file rendered ahead,
|
|
127
|
+
* unless the reader asked for its code with `plain`.
|
|
128
|
+
*/
|
|
129
|
+
export const loadFile = async (
|
|
130
|
+
client: QueryClient,
|
|
131
|
+
place: RepoPlace,
|
|
132
|
+
splat: string,
|
|
133
|
+
plain = false,
|
|
134
|
+
): Promise<(CodeLoad & { readonly file: FileAt }) | undefined> => {
|
|
135
|
+
const { at, head } = await refAndHead(client, place, splat);
|
|
136
|
+
if (at === undefined || head === null || at.path === '') return undefined;
|
|
137
|
+
|
|
138
|
+
const [walked, file] = await Promise.all([
|
|
139
|
+
walk(client, place, head.tree, parentOf(at.path)),
|
|
140
|
+
readFile(client, place, head.sha, at.path),
|
|
141
|
+
]);
|
|
142
|
+
if (walked === undefined || file === null) return undefined;
|
|
143
|
+
|
|
144
|
+
if (!plain) await renderAhead(client, at, file);
|
|
145
|
+
|
|
146
|
+
return { at, head, walked, file };
|
|
147
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
|
|
3
|
+
import { readAhead } from '../clients/cached.ts';
|
|
4
|
+
import type { FileContext } from '../markdown/context.ts';
|
|
5
|
+
import { markdownQuery } from '../markdown/query.ts';
|
|
6
|
+
import type { FileAt } from './files.ts';
|
|
7
|
+
import { nameOf, parentOf, type At } from './places.ts';
|
|
8
|
+
import type { Entry, Folder } from './trees.ts';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A Markdown file's page and a repository's README show it rendered, through APP1's `Markdown`,
|
|
12
|
+
* its relative links and images resolved from the file's folder at the page's ref. The loader
|
|
13
|
+
* renders it ahead, so the server's page carries it.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** The extensions GitHub renders as Markdown, as Linguist names them. */
|
|
17
|
+
const markdownExtensions: ReadonlySet<string> = new Set([
|
|
18
|
+
'md',
|
|
19
|
+
'markdown',
|
|
20
|
+
'mdown',
|
|
21
|
+
'mdwn',
|
|
22
|
+
'mkd',
|
|
23
|
+
'mkdn',
|
|
24
|
+
'mkdown',
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
/** Whether GitHub renders a file of this name as Markdown. */
|
|
28
|
+
export const isMarkdown = (path: string) => {
|
|
29
|
+
const name = nameOf(path);
|
|
30
|
+
const dot = name.lastIndexOf('.');
|
|
31
|
+
|
|
32
|
+
return dot > 0 && markdownExtensions.has(name.slice(dot + 1).toLowerCase());
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Where a file's Markdown resolves its relative links and images: its folder, at the page's ref. */
|
|
36
|
+
export const contextOf = (at: At, path: string): FileContext => ({
|
|
37
|
+
kind: 'file',
|
|
38
|
+
repo: `${at.owner}/${at.repo}`,
|
|
39
|
+
ref: at.ref.name,
|
|
40
|
+
dir: parentOf(path),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/** A file's text when its page may show it rendered: a Markdown file the page holds as text. */
|
|
44
|
+
export const markdownOf = (file: FileAt) =>
|
|
45
|
+
file.shown.kind === 'text' && isMarkdown(file.path) ? file.shown.text : undefined;
|
|
46
|
+
|
|
47
|
+
/** A folder's README: its first file named `README`, any extension, as the drop-in's `/readme` finds it. */
|
|
48
|
+
export const readmeIn = (folder: Folder): Entry | undefined =>
|
|
49
|
+
folder.entries.find((entry) => entry.kind === 'file' && /^readme(\.|$)/i.test(entry.name));
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A Markdown file rendered ahead, for the server's page: nothing for any other file. A render that
|
|
53
|
+
* fails leaves the page to `Markdown`, which draws the text unlinked and tries again.
|
|
54
|
+
*/
|
|
55
|
+
export const renderAhead = async (client: QueryClient, at: At, file: FileAt) => {
|
|
56
|
+
const text = markdownOf(file);
|
|
57
|
+
if (text !== undefined) await readAhead(client, markdownQuery(text, contextOf(at, file.path)));
|
|
58
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** Where a code page is: a repository, the ref it reads at, and a path in its tree. */
|
|
2
|
+
|
|
3
|
+
/** A repository by its owner's login and its name. */
|
|
4
|
+
export interface RepoPlace {
|
|
5
|
+
readonly owner: string;
|
|
6
|
+
readonly repo: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** What a ref in a URL names: a branch, a tag, or a commit by its full ID. */
|
|
10
|
+
export type RefKind = 'branch' | 'tag' | 'commit';
|
|
11
|
+
|
|
12
|
+
/** A ref, as a URL names it and the drop-in found it. */
|
|
13
|
+
export interface Ref {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly kind: RefKind;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** A path in a repository at a ref: `''` is its root. */
|
|
19
|
+
export interface At extends RepoPlace {
|
|
20
|
+
readonly ref: Ref;
|
|
21
|
+
readonly path: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A commit's full ID, as Git writes one in SHA-1 or SHA-256. */
|
|
25
|
+
export const isOid = (text: string) => /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(text);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The revision the drop-in's `?sha=` and `?ref=` read for `ref`: a branch's or a tag's full name,
|
|
29
|
+
* so a branch and a tag of one name never mix, as `gitrevisions` would mix them.
|
|
30
|
+
*/
|
|
31
|
+
export const revisionOf = (ref: Ref) => {
|
|
32
|
+
switch (ref.kind) {
|
|
33
|
+
case 'branch':
|
|
34
|
+
return `refs/heads/${ref.name}`;
|
|
35
|
+
case 'tag':
|
|
36
|
+
return `refs/tags/${ref.name}`;
|
|
37
|
+
case 'commit':
|
|
38
|
+
return ref.name;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** Each segment of `text` encoded as a URL's path takes it, its slashes kept. */
|
|
43
|
+
const pathOf = (text: string) => text.split('/').map(encodeURIComponent).join('/');
|
|
44
|
+
|
|
45
|
+
const joined = (...parts: readonly string[]) => parts.filter((part) => part !== '').join('/');
|
|
46
|
+
|
|
47
|
+
/** A repository's home. */
|
|
48
|
+
export const repoHref = (place: RepoPlace) => `/${pathOf(place.owner)}/${pathOf(place.repo)}`;
|
|
49
|
+
|
|
50
|
+
/** A folder's page, or the root's when `path` is `''`. */
|
|
51
|
+
export const treeHref = (place: RepoPlace, ref: string, path: string) =>
|
|
52
|
+
`${repoHref(place)}/tree/${pathOf(joined(ref, path))}`;
|
|
53
|
+
|
|
54
|
+
/** A release's page, by its tag, the tag's slashes kept, as the tag route's splat reads it. */
|
|
55
|
+
export const releaseHref = (place: RepoPlace, tag: string) =>
|
|
56
|
+
`${repoHref(place)}/releases/tag/${pathOf(tag)}`;
|
|
57
|
+
|
|
58
|
+
/** A release's edit form, by its tag, its slashes kept. */
|
|
59
|
+
export const releaseEditHref = (place: RepoPlace, tag: string) =>
|
|
60
|
+
`${repoHref(place)}/releases/edit/${pathOf(tag)}`;
|
|
61
|
+
|
|
62
|
+
/** A file's page. */
|
|
63
|
+
export const blobHref = (place: RepoPlace, ref: string, path: string) =>
|
|
64
|
+
`${repoHref(place)}/blob/${pathOf(joined(ref, path))}`;
|
|
65
|
+
|
|
66
|
+
/** The history of `ref`, or of the path at it. */
|
|
67
|
+
export const commitsHref = (place: RepoPlace, ref: string, path = '') =>
|
|
68
|
+
`${repoHref(place)}/commits/${pathOf(joined(ref, path))}`;
|
|
69
|
+
|
|
70
|
+
/** One commit's page. */
|
|
71
|
+
export const commitHref = (place: RepoPlace, oid: string) => `${repoHref(place)}/commit/${oid}`;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A file's bytes at the drop-in's raw route, as plain text no browser runs (Q310). Its ref is one
|
|
75
|
+
* segment, so a branch's slashes are encoded within it.
|
|
76
|
+
*/
|
|
77
|
+
export const rawHref = (place: RepoPlace, ref: string, path: string) =>
|
|
78
|
+
`${repoHref(place)}/raw/${encodeURIComponent(ref)}/${pathOf(path)}`;
|
|
79
|
+
|
|
80
|
+
/** The last segment of `path`: a file's name. */
|
|
81
|
+
export const nameOf = (path: string) => path.slice(path.lastIndexOf('/') + 1);
|
|
82
|
+
|
|
83
|
+
/** The folder holding `path`, `''` for the root's own entries. */
|
|
84
|
+
export const parentOf = (path: string) => path.slice(0, Math.max(0, path.lastIndexOf('/')));
|
|
85
|
+
|
|
86
|
+
/** `path` and each folder above it, from the root's first: `a/b` is `['a', 'a/b']`. */
|
|
87
|
+
export const ancestry = (path: string) =>
|
|
88
|
+
path === '' ? [] : path.split('/').map((_, index, parts) => parts.slice(0, index + 1).join('/'));
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import * as Schema from 'effect/Schema';
|
|
2
|
+
|
|
3
|
+
import { query } from '../clients/clients.ts';
|
|
4
|
+
import type { RepoPlace } from './places.ts';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The app's GraphQL read of a page of refs, as `packages/github`'s
|
|
8
|
+
* `graphql/fixtures/app/RepositoryRefs.graphql` holds it, so the drop-in's served schema is held to
|
|
9
|
+
* it (Q527): each ref's tip with its author and date, and the default branch's.
|
|
10
|
+
*/
|
|
11
|
+
export const refsOperation = `query RepositoryRefs(
|
|
12
|
+
$owner: String!
|
|
13
|
+
$name: String!
|
|
14
|
+
$refPrefix: String!
|
|
15
|
+
$first: Int!
|
|
16
|
+
$after: String
|
|
17
|
+
$query: String
|
|
18
|
+
) {
|
|
19
|
+
repository(owner: $owner, name: $name) {
|
|
20
|
+
defaultBranchRef {
|
|
21
|
+
name
|
|
22
|
+
target {
|
|
23
|
+
oid
|
|
24
|
+
...Tip
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
refs(refPrefix: $refPrefix, first: $first, after: $after, query: $query) {
|
|
28
|
+
nodes {
|
|
29
|
+
name
|
|
30
|
+
target {
|
|
31
|
+
oid
|
|
32
|
+
...Tip
|
|
33
|
+
... on Tag {
|
|
34
|
+
target {
|
|
35
|
+
...Tip
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
pageInfo {
|
|
41
|
+
hasNextPage
|
|
42
|
+
endCursor
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
fragment Tip on Commit {
|
|
49
|
+
oid
|
|
50
|
+
author {
|
|
51
|
+
name
|
|
52
|
+
email
|
|
53
|
+
date
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
const Actor = Schema.Struct({
|
|
59
|
+
name: Schema.NullOr(Schema.String),
|
|
60
|
+
email: Schema.NullOr(Schema.String),
|
|
61
|
+
date: Schema.NullOr(Schema.String),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/** A commit's fields `Tip` selects, which a tree or a blob doesn't have. */
|
|
65
|
+
const Tip = Schema.Struct({
|
|
66
|
+
oid: Schema.optionalKey(Schema.String),
|
|
67
|
+
author: Schema.optionalKey(Schema.NullOr(Actor)),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/** A ref's target: a commit, an annotated tag with its own target, or a tree or a blob. */
|
|
71
|
+
const Target = Schema.Struct({
|
|
72
|
+
oid: Schema.String,
|
|
73
|
+
author: Schema.optionalKey(Schema.NullOr(Actor)),
|
|
74
|
+
target: Schema.optionalKey(Tip),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const RefNode = Schema.Struct({ name: Schema.String, target: Schema.NullOr(Target) });
|
|
78
|
+
|
|
79
|
+
const RefsAnswer = Schema.Struct({
|
|
80
|
+
repository: Schema.NullOr(
|
|
81
|
+
Schema.Struct({
|
|
82
|
+
defaultBranchRef: Schema.NullOr(RefNode),
|
|
83
|
+
refs: Schema.NullOr(
|
|
84
|
+
Schema.Struct({
|
|
85
|
+
nodes: Schema.Array(RefNode),
|
|
86
|
+
pageInfo: Schema.Struct({
|
|
87
|
+
hasNextPage: Schema.Boolean,
|
|
88
|
+
endCursor: Schema.NullOr(Schema.String),
|
|
89
|
+
}),
|
|
90
|
+
}),
|
|
91
|
+
),
|
|
92
|
+
}),
|
|
93
|
+
),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
/** Who made a ref's tip commit, and when, as Git's author line says. */
|
|
97
|
+
export interface Author {
|
|
98
|
+
readonly name: string;
|
|
99
|
+
readonly date: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** A ref on a page: its short name, its tip commit, and that commit's author, where it has one. */
|
|
103
|
+
export interface RefRow {
|
|
104
|
+
readonly name: string;
|
|
105
|
+
readonly commit: string | undefined;
|
|
106
|
+
readonly author: Author | undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A ref's row from its node: an annotated tag's tip is its target's, and a ref whose chain ends at
|
|
111
|
+
* a tree or a blob names no commit.
|
|
112
|
+
*/
|
|
113
|
+
const rowOf = (node: typeof RefNode.Type): RefRow => {
|
|
114
|
+
const tip = node.target?.target ?? node.target;
|
|
115
|
+
const named = tip?.author;
|
|
116
|
+
const author =
|
|
117
|
+
named?.name === null || named?.name === undefined || named.date === null
|
|
118
|
+
? undefined
|
|
119
|
+
: { name: named.name, date: named.date };
|
|
120
|
+
|
|
121
|
+
return { name: node.name, commit: tip?.author === undefined ? undefined : tip.oid, author };
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** One page of refs: its rows, the default branch's row, and the cursor of the next, if any. */
|
|
125
|
+
export interface RefPage {
|
|
126
|
+
readonly rows: readonly RefRow[];
|
|
127
|
+
readonly defaultBranch: RefRow | undefined;
|
|
128
|
+
readonly next: string | undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Which refs a page asks for: under `prefix`, `first` of them after `after`, matching `search`. */
|
|
132
|
+
export interface RefAsk {
|
|
133
|
+
readonly prefix: 'refs/heads/' | 'refs/tags/';
|
|
134
|
+
readonly first: number;
|
|
135
|
+
readonly after: string | undefined;
|
|
136
|
+
readonly search: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A page of the repo's refs, in one call: the drop-in lists them by name, and a page with
|
|
141
|
+
* `hasNextPage` names the next one's cursor even when it holds fewer than `first`.
|
|
142
|
+
*/
|
|
143
|
+
export const readRefPage = async (place: RepoPlace, ask: RefAsk): Promise<RefPage> => {
|
|
144
|
+
const variables = {
|
|
145
|
+
owner: place.owner,
|
|
146
|
+
name: place.repo,
|
|
147
|
+
refPrefix: ask.prefix,
|
|
148
|
+
first: ask.first,
|
|
149
|
+
after: ask.after ?? null,
|
|
150
|
+
query: ask.search === '' ? null : ask.search,
|
|
151
|
+
};
|
|
152
|
+
const { repository } = await query("The refs didn't load", refsOperation, variables, RefsAnswer);
|
|
153
|
+
if (repository === null || repository.refs === null) throw new Error("The refs didn't load");
|
|
154
|
+
|
|
155
|
+
const { nodes, pageInfo } = repository.refs;
|
|
156
|
+
const next = pageInfo.hasNextPage && pageInfo.endCursor !== null ? pageInfo.endCursor : undefined;
|
|
157
|
+
const defaultRef = repository.defaultBranchRef;
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
rows: nodes.map(rowOf),
|
|
161
|
+
defaultBranch: defaultRef === null ? undefined : rowOf(defaultRef),
|
|
162
|
+
next,
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const firstPage: string | undefined = undefined;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* A list's pages of refs, read a page at a time as the reader asks for more, for a place's prefix,
|
|
170
|
+
* page size and search.
|
|
171
|
+
*/
|
|
172
|
+
export const refPages = (place: RepoPlace, ask: Omit<RefAsk, 'after'>) => ({
|
|
173
|
+
queryKey: ['ref-pages', place.owner, place.repo, ask.prefix, ask.first, ask.search] as const,
|
|
174
|
+
queryFn: ({ pageParam }: { readonly pageParam: string | undefined }) =>
|
|
175
|
+
readRefPage(place, { ...ask, after: pageParam }),
|
|
176
|
+
initialPageParam: firstPage,
|
|
177
|
+
getNextPageParam: (last: RefPage) => last.next,
|
|
178
|
+
staleTime: 30_000,
|
|
179
|
+
});
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query';
|
|
2
|
+
import { GitBranchIcon, GitCommitIcon, TagIcon } from 'lucide-react';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import { Alert, AlertDescription } from '../components/ui/alert.tsx';
|
|
6
|
+
import { Button } from '../components/ui/button.tsx';
|
|
7
|
+
import {
|
|
8
|
+
Combobox,
|
|
9
|
+
ComboboxContent,
|
|
10
|
+
ComboboxEmpty,
|
|
11
|
+
ComboboxInput,
|
|
12
|
+
ComboboxItem,
|
|
13
|
+
ComboboxList,
|
|
14
|
+
ComboboxTrigger,
|
|
15
|
+
} from '../components/ui/combobox.tsx';
|
|
16
|
+
import { Skeleton } from '../components/ui/skeleton.tsx';
|
|
17
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../components/ui/tabs.tsx';
|
|
18
|
+
import { nextCursor } from '../hooks/repos.ts';
|
|
19
|
+
import { Go } from './controls.tsx';
|
|
20
|
+
import type { Ref, RepoPlace } from './places.ts';
|
|
21
|
+
import { refNames } from './repo.ts';
|
|
22
|
+
|
|
23
|
+
/** Which of a repo's refs a list names. */
|
|
24
|
+
export type Kind = 'branches' | 'tags';
|
|
25
|
+
|
|
26
|
+
const refIcons = { branch: GitBranchIcon, tag: TagIcon, commit: GitCommitIcon } as const;
|
|
27
|
+
|
|
28
|
+
const firstPage: string | undefined = undefined;
|
|
29
|
+
|
|
30
|
+
const noNames: readonly string[] = [];
|
|
31
|
+
|
|
32
|
+
interface NamesPage {
|
|
33
|
+
readonly names: readonly string[];
|
|
34
|
+
readonly next: string | undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A kind's names, a page of 100 at a time: the switcher's list, which the palette's branches and
|
|
39
|
+
* tags read too, from the same cache.
|
|
40
|
+
*/
|
|
41
|
+
export const refNameList = (place: RepoPlace, kind: Kind) =>
|
|
42
|
+
infiniteQueryOptions({
|
|
43
|
+
queryKey: ['refs', place.owner, place.repo, kind],
|
|
44
|
+
queryFn: async ({
|
|
45
|
+
pageParam,
|
|
46
|
+
}: {
|
|
47
|
+
readonly pageParam: string | undefined;
|
|
48
|
+
}): Promise<NamesPage> => {
|
|
49
|
+
const page = await refNames(place, kind, pageParam);
|
|
50
|
+
|
|
51
|
+
return { names: page.names, next: nextCursor(page.link) };
|
|
52
|
+
},
|
|
53
|
+
initialPageParam: firstPage,
|
|
54
|
+
getNextPageParam: (last: NamesPage) => last.next,
|
|
55
|
+
staleTime: 30_000,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/** A kind's names, read only while the switcher is open. */
|
|
59
|
+
const useNames = (place: RepoPlace, kind: Kind, open: boolean) =>
|
|
60
|
+
useInfiniteQuery({ ...refNameList(place, kind), enabled: open });
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* A kind's names as the switcher lists them: its filter, what it holds, and more to load. Each is
|
|
64
|
+
* a link to the page at that ref, by a click or by Enter on the one highlighted.
|
|
65
|
+
*/
|
|
66
|
+
function Names({
|
|
67
|
+
names,
|
|
68
|
+
kind,
|
|
69
|
+
hrefOf,
|
|
70
|
+
onPick,
|
|
71
|
+
}: {
|
|
72
|
+
readonly names: ReturnType<typeof useNames>;
|
|
73
|
+
readonly kind: Kind;
|
|
74
|
+
readonly hrefOf: (ref: string) => string;
|
|
75
|
+
readonly onPick: () => void;
|
|
76
|
+
}) {
|
|
77
|
+
const loaded = names.data?.pages.flatMap((page) => page.names) ?? [];
|
|
78
|
+
const what = kind === 'branches' ? 'branch' : 'tag';
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<>
|
|
82
|
+
<ComboboxInput
|
|
83
|
+
showTrigger={false}
|
|
84
|
+
aria-label={`Find a ${what}`}
|
|
85
|
+
placeholder={`Find a ${what}…`}
|
|
86
|
+
/>
|
|
87
|
+
{names.isPending && <Skeleton className="m-1.5 h-24" />}
|
|
88
|
+
{names.error !== null && (
|
|
89
|
+
<Alert variant="destructive" className="m-1.5 w-auto">
|
|
90
|
+
<AlertDescription>{names.error.message}</AlertDescription>
|
|
91
|
+
</Alert>
|
|
92
|
+
)}
|
|
93
|
+
{names.isSuccess && (
|
|
94
|
+
<ComboboxEmpty>
|
|
95
|
+
{loaded.length === 0 ? `No ${kind} yet.` : `No ${kind} match in those loaded.`}
|
|
96
|
+
</ComboboxEmpty>
|
|
97
|
+
)}
|
|
98
|
+
<ComboboxList aria-label={kind === 'branches' ? 'Branches' : 'Tags'}>
|
|
99
|
+
{(name: string) => (
|
|
100
|
+
<ComboboxItem
|
|
101
|
+
key={name}
|
|
102
|
+
value={name}
|
|
103
|
+
render={<Go href={hrefOf(name)} onClick={onPick} />}
|
|
104
|
+
>
|
|
105
|
+
<span className="break-all">{name}</span>
|
|
106
|
+
</ComboboxItem>
|
|
107
|
+
)}
|
|
108
|
+
</ComboboxList>
|
|
109
|
+
{names.hasNextPage && (
|
|
110
|
+
<Button
|
|
111
|
+
variant="ghost"
|
|
112
|
+
size="sm"
|
|
113
|
+
className="mx-1.5 mb-1.5"
|
|
114
|
+
disabled={names.isFetchingNextPage}
|
|
115
|
+
onClick={() => void names.fetchNextPage()}
|
|
116
|
+
>
|
|
117
|
+
{names.isFetchingNextPage ? 'Loading…' : `Load more ${kind}`}
|
|
118
|
+
</Button>
|
|
119
|
+
)}
|
|
120
|
+
</>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The page's ref, and the branches and tags to read it at instead: the same page at another ref.
|
|
126
|
+
* The lists load when it opens, a page of 100 at a time, and the filter reads the pages loaded.
|
|
127
|
+
* `side` names which of a page's refs it is, such as a comparison's base. It's `lg`, 40px, beside
|
|
128
|
+
* a page's other 40px controls, and `sm`, 28px, in a muted bar of 28px buttons, as a file's is.
|
|
129
|
+
*/
|
|
130
|
+
export function RefSwitcher({
|
|
131
|
+
place,
|
|
132
|
+
here,
|
|
133
|
+
hrefOf,
|
|
134
|
+
side,
|
|
135
|
+
size = 'lg',
|
|
136
|
+
}: {
|
|
137
|
+
readonly place: RepoPlace;
|
|
138
|
+
readonly here: Ref;
|
|
139
|
+
readonly hrefOf: (ref: string) => string;
|
|
140
|
+
readonly side?: string;
|
|
141
|
+
readonly size?: 'sm' | 'lg';
|
|
142
|
+
}) {
|
|
143
|
+
const [open, setOpen] = useState(false);
|
|
144
|
+
const [kind, setKind] = useState<Kind>(here.kind === 'tag' ? 'tags' : 'branches');
|
|
145
|
+
const names = useNames(place, kind, open);
|
|
146
|
+
const Icon = refIcons[here.kind];
|
|
147
|
+
const name = here.kind === 'commit' ? here.name.slice(0, 7) : here.name;
|
|
148
|
+
const current = here.kind === (kind === 'branches' ? 'branch' : 'tag') ? here.name : null;
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<Combobox
|
|
152
|
+
items={names.data?.pages.flatMap((page) => page.names) ?? noNames}
|
|
153
|
+
value={current}
|
|
154
|
+
open={open}
|
|
155
|
+
onOpenChange={setOpen}
|
|
156
|
+
autoHighlight
|
|
157
|
+
>
|
|
158
|
+
<ComboboxTrigger
|
|
159
|
+
render={
|
|
160
|
+
<Button
|
|
161
|
+
variant="outline"
|
|
162
|
+
size={size}
|
|
163
|
+
className="max-w-56"
|
|
164
|
+
aria-label={`Switch ${side === undefined ? '' : `${side} `}branches or tags: ${name}`}
|
|
165
|
+
/>
|
|
166
|
+
}
|
|
167
|
+
>
|
|
168
|
+
<Icon data-icon="inline-start" />
|
|
169
|
+
{side !== undefined && <span className="text-muted-foreground">{side}:</span>}
|
|
170
|
+
<span className="truncate font-mono">{name}</span>
|
|
171
|
+
</ComboboxTrigger>
|
|
172
|
+
<ComboboxContent aria-label="Switch branches or tags" className="w-80">
|
|
173
|
+
<Tabs
|
|
174
|
+
value={kind}
|
|
175
|
+
onValueChange={(value) => setKind(value === 'tags' ? 'tags' : 'branches')}
|
|
176
|
+
className="gap-0"
|
|
177
|
+
>
|
|
178
|
+
<TabsList variant="line" className="h-10! w-full justify-start border-b px-2">
|
|
179
|
+
<TabsTrigger value="branches" className="flex-none px-2">
|
|
180
|
+
<GitBranchIcon data-icon="inline-start" />
|
|
181
|
+
Branches
|
|
182
|
+
</TabsTrigger>
|
|
183
|
+
<TabsTrigger value="tags" className="flex-none px-2">
|
|
184
|
+
<TagIcon data-icon="inline-start" />
|
|
185
|
+
Tags
|
|
186
|
+
</TabsTrigger>
|
|
187
|
+
</TabsList>
|
|
188
|
+
{/* One panel, the open tab's, so the filter keeps what's typed across a switch. */}
|
|
189
|
+
<TabsContent value={kind} className="flex flex-col">
|
|
190
|
+
<Names names={names} kind={kind} hrefOf={hrefOf} onPick={() => setOpen(false)} />
|
|
191
|
+
<Go
|
|
192
|
+
href={`/${place.owner}/${place.repo}/${kind}`}
|
|
193
|
+
onClick={() => setOpen(false)}
|
|
194
|
+
className="pressable pressable-row border-t px-3.5 py-2.5 text-sm hover:bg-accent"
|
|
195
|
+
>
|
|
196
|
+
View all {kind}
|
|
197
|
+
</Go>
|
|
198
|
+
</TabsContent>
|
|
199
|
+
</Tabs>
|
|
200
|
+
</ComboboxContent>
|
|
201
|
+
</Combobox>
|
|
202
|
+
);
|
|
203
|
+
}
|