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,487 @@
|
|
|
1
|
+
import { type QueryClient, useQueries, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import {
|
|
3
|
+
ArrowRightIcon,
|
|
4
|
+
BookMarkedIcon,
|
|
5
|
+
Building2Icon,
|
|
6
|
+
CircleDotIcon,
|
|
7
|
+
FileIcon,
|
|
8
|
+
GitBranchIcon,
|
|
9
|
+
GitCommitIcon,
|
|
10
|
+
GitPullRequestIcon,
|
|
11
|
+
type LucideIcon,
|
|
12
|
+
TagIcon,
|
|
13
|
+
TerminalIcon,
|
|
14
|
+
UserIcon,
|
|
15
|
+
} from 'lucide-react';
|
|
16
|
+
import { useEffect, useState } from 'react';
|
|
17
|
+
|
|
18
|
+
import { type Kind, refNameList } from '../code/ref-switcher.tsx';
|
|
19
|
+
import { blobHref, treeHref } from '../code/places.ts';
|
|
20
|
+
import { headCommit } from '../code/refs.ts';
|
|
21
|
+
import { allFiles } from '../code/trees.ts';
|
|
22
|
+
import { switcherList } from '../components/shell/owner-repos.tsx';
|
|
23
|
+
import { sectionIcon } from '../components/shell/sections.ts';
|
|
24
|
+
import type { PageOperation } from '../clients/allowed.ts';
|
|
25
|
+
import { allowedHere } from '../hooks/allowed.ts';
|
|
26
|
+
import { type Owner, repoList } from '../hooks/repos.ts';
|
|
27
|
+
import { settingsOpen } from '../settings/settings-layout.tsx';
|
|
28
|
+
import { type RecentPlace, recentPlaces } from './recent.ts';
|
|
29
|
+
import { issueSearch, orgMembers, resultsMost, useSettled } from './server.ts';
|
|
30
|
+
import {
|
|
31
|
+
bestOf,
|
|
32
|
+
type Here,
|
|
33
|
+
issueQueryOf,
|
|
34
|
+
jumpOf,
|
|
35
|
+
type Jump,
|
|
36
|
+
numberJump,
|
|
37
|
+
pagesOf,
|
|
38
|
+
repoPath,
|
|
39
|
+
symbols,
|
|
40
|
+
type Target,
|
|
41
|
+
type Typed,
|
|
42
|
+
} from './targets.ts';
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* What the palette lists for what was typed, group by group: the local ones at once, from what
|
|
46
|
+
* the page and the switchers' reads already hold, and a mode's server results once typing stops.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/** Where the palette is, and who uses it: what its rows and commands work from. */
|
|
50
|
+
export interface PaletteAt {
|
|
51
|
+
readonly here: Here;
|
|
52
|
+
readonly viewer: string;
|
|
53
|
+
/** The orgs the viewer is in. */
|
|
54
|
+
readonly orgs: readonly string[];
|
|
55
|
+
/** The page's repo's clone URL, once its page has read the repo. */
|
|
56
|
+
readonly cloneUrl: string | undefined;
|
|
57
|
+
/** Where switching to another owner goes: the same section, at its level. */
|
|
58
|
+
readonly ownerHref: (owner: string) => string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** What picking a row does: go to a page, look up a commit first, or run a command. */
|
|
62
|
+
export type Act =
|
|
63
|
+
| { readonly kind: 'go'; readonly href: string; readonly keep?: RecentPlace }
|
|
64
|
+
| { readonly kind: 'jump'; readonly jump: Jump }
|
|
65
|
+
| { readonly kind: 'run'; readonly run: () => void; readonly stays?: boolean };
|
|
66
|
+
|
|
67
|
+
/** One of the palette's rows. Its `id` is unique among them all, and cmdk's value for it. */
|
|
68
|
+
export interface Row {
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly label: string;
|
|
71
|
+
readonly note?: string | undefined;
|
|
72
|
+
readonly icon: LucideIcon;
|
|
73
|
+
readonly act: Act;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** What a server group shows besides its rows: still searching, failed, or only the first found. */
|
|
77
|
+
export type Status =
|
|
78
|
+
| { readonly kind: 'searching' }
|
|
79
|
+
| { readonly kind: 'failed'; readonly retry: () => void }
|
|
80
|
+
| { readonly kind: 'incomplete' }
|
|
81
|
+
| { readonly kind: 'hint'; readonly words: string };
|
|
82
|
+
|
|
83
|
+
/** A group of rows under its heading. */
|
|
84
|
+
export interface Group {
|
|
85
|
+
readonly heading: string;
|
|
86
|
+
readonly rows: readonly Row[];
|
|
87
|
+
readonly status?: Status | undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The owners whose repos the viewer sees in the switchers: theirs, then their orgs'. */
|
|
91
|
+
export const ownersOf = (at: PaletteAt): readonly Owner[] => [
|
|
92
|
+
{ kind: 'viewer', login: at.viewer },
|
|
93
|
+
...at.orgs.map((login): Owner => ({ kind: 'org', login })),
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
/** The page's repo, as the code pages name it, or `undefined` off a repo. */
|
|
97
|
+
export const placeOf = (here: Here) =>
|
|
98
|
+
here.owner !== undefined && here.repo !== undefined
|
|
99
|
+
? { owner: here.owner, repo: here.repo }
|
|
100
|
+
: undefined;
|
|
101
|
+
|
|
102
|
+
const refKinds: readonly Kind[] = ['branches', 'tags'];
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Reads ahead what the palette lists with no mode, from the switchers' own reads under their own
|
|
106
|
+
* keys: each owner's repos and, in a repo, its branches and tags. A read still fresh reads nothing.
|
|
107
|
+
*/
|
|
108
|
+
export const prefetchLists = (client: QueryClient, at: PaletteAt) => {
|
|
109
|
+
for (const owner of ownersOf(at)) {
|
|
110
|
+
void client.prefetchInfiniteQuery({ ...repoList(owner, switcherList), staleTime: 30_000 });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const place = placeOf(at.here);
|
|
114
|
+
if (place === undefined) return;
|
|
115
|
+
|
|
116
|
+
for (const kind of refKinds) void client.prefetchInfiniteQuery(refNameList(place, kind));
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** Draws again whenever a read lands in the cache, so lists read ahead show once they arrive. */
|
|
120
|
+
const useCacheLanded = () => {
|
|
121
|
+
const client = useQueryClient();
|
|
122
|
+
const [, setLanded] = useState(0);
|
|
123
|
+
useEffect(
|
|
124
|
+
() =>
|
|
125
|
+
client.getQueryCache().subscribe((event) => {
|
|
126
|
+
if (event.type === 'updated' && event.action.type === 'success') {
|
|
127
|
+
setLanded((count) => count + 1);
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
[client],
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
return client;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const segment = encodeURIComponent;
|
|
137
|
+
|
|
138
|
+
const targetRow = (kind: string, target: Target, icon: LucideIcon): Row => ({
|
|
139
|
+
id: `${kind}:${target.href}`,
|
|
140
|
+
label: target.label,
|
|
141
|
+
note: target.note,
|
|
142
|
+
icon,
|
|
143
|
+
act: { kind: 'go', href: target.href },
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const recentIcons = { repo: BookMarkedIcon, issue: CircleDotIcon, pull: GitPullRequestIcon };
|
|
147
|
+
|
|
148
|
+
const recentRow = (place: RecentPlace): Row => ({
|
|
149
|
+
id: `recent:${place.href}`,
|
|
150
|
+
label: place.label,
|
|
151
|
+
note: place.note,
|
|
152
|
+
icon: recentIcons[place.kind],
|
|
153
|
+
act: { kind: 'go', href: place.href },
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const jumpRow = (jump: Jump): Row =>
|
|
157
|
+
jump.kind === 'page'
|
|
158
|
+
? { ...targetRow('jump', jump.target, ArrowRightIcon), act: { kind: 'jump', jump } }
|
|
159
|
+
: {
|
|
160
|
+
id: `jump:commit:${jump.commit.sha}`,
|
|
161
|
+
label: jump.commit.sha.slice(0, 12),
|
|
162
|
+
note: `Commit in ${jump.commit.owner}/${jump.commit.repo}`,
|
|
163
|
+
icon: GitCommitIcon,
|
|
164
|
+
act: { kind: 'jump', jump },
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const wordsOf = (row: Row) => (row.note === undefined ? row.label : `${row.label} ${row.note}`);
|
|
168
|
+
|
|
169
|
+
const noOperations: ReadonlySet<PageOperation> = new Set();
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* What the viewer may do on the page's repo, as its route read it ahead: the palette reads nothing
|
|
173
|
+
* of its own, so before that answer lands, and off a repo, it offers no gated row.
|
|
174
|
+
*/
|
|
175
|
+
export const useAllowedAt = (here: Here): ReadonlySet<PageOperation> =>
|
|
176
|
+
useQuery({
|
|
177
|
+
...allowedHere({ owner: here.owner ?? '', repo: here.repo ?? '' }),
|
|
178
|
+
enabled: false,
|
|
179
|
+
}).data ?? noOperations;
|
|
180
|
+
|
|
181
|
+
/** Whether `page` is one of the repo's settings, which open only as the sidebar's Settings does. */
|
|
182
|
+
const repoSettings = (page: Target, here: Here) =>
|
|
183
|
+
page.section === 'settings' &&
|
|
184
|
+
here.owner !== undefined &&
|
|
185
|
+
here.repo !== undefined &&
|
|
186
|
+
page.href.startsWith(`${repoPath(here.owner, here.repo)}/settings`);
|
|
187
|
+
|
|
188
|
+
/** The rows with no mode: what a pasted value names, then recent places, pages, repos, orgs and refs. */
|
|
189
|
+
const useFound = (at: PaletteAt, text: string): readonly Group[] => {
|
|
190
|
+
const client = useCacheLanded();
|
|
191
|
+
const place = placeOf(at.here);
|
|
192
|
+
const owners = ownersOf(at);
|
|
193
|
+
const allowed = useAllowedAt(at.here);
|
|
194
|
+
|
|
195
|
+
// Each page with its sidebar section's icon, a repo's Code its own, and any other a file's.
|
|
196
|
+
const shown = pagesOf(at.here).filter(
|
|
197
|
+
(page) => !repoSettings(page, at.here) || settingsOpen(allowed),
|
|
198
|
+
);
|
|
199
|
+
const pages = shown.map((page) =>
|
|
200
|
+
targetRow(
|
|
201
|
+
'page',
|
|
202
|
+
page,
|
|
203
|
+
page.section === undefined ? FileIcon : sectionIcon(page.section, page.section === 'code'),
|
|
204
|
+
),
|
|
205
|
+
);
|
|
206
|
+
const recent = recentPlaces(at.viewer).map(recentRow);
|
|
207
|
+
|
|
208
|
+
if (text.trim() === '') {
|
|
209
|
+
return [
|
|
210
|
+
{ heading: 'Recent', rows: recent.slice(0, resultsMost) },
|
|
211
|
+
{ heading: 'Pages', rows: pages.slice(0, resultsMost) },
|
|
212
|
+
];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// The page's own owner's repos first, so a tie goes to the repo nearest.
|
|
216
|
+
const ordered = [...owners].sort(
|
|
217
|
+
(a, b) => Number(b.login === at.here.owner) - Number(a.login === at.here.owner),
|
|
218
|
+
);
|
|
219
|
+
const repos = ordered.flatMap((owner) =>
|
|
220
|
+
(client.getQueryData(repoList(owner, switcherList).queryKey)?.pages ?? []).flatMap((page) =>
|
|
221
|
+
page.repos.map((repo): Row => ({
|
|
222
|
+
id: `repo:${owner.login}/${repo.name}`,
|
|
223
|
+
label: `${owner.login}/${repo.name}`,
|
|
224
|
+
icon: BookMarkedIcon,
|
|
225
|
+
act: {
|
|
226
|
+
kind: 'go',
|
|
227
|
+
href: `/${segment(owner.login)}/${segment(repo.name)}`,
|
|
228
|
+
keep: {
|
|
229
|
+
kind: 'repo',
|
|
230
|
+
label: `${owner.login}/${repo.name}`,
|
|
231
|
+
href: `/${segment(owner.login)}/${segment(repo.name)}`,
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
})),
|
|
235
|
+
),
|
|
236
|
+
);
|
|
237
|
+
const orgs = owners.map((owner): Row => ({
|
|
238
|
+
id: `owner:${owner.login}`,
|
|
239
|
+
label: owner.login,
|
|
240
|
+
note: owner.kind === 'viewer' ? 'You' : 'Organization',
|
|
241
|
+
icon: owner.kind === 'viewer' ? UserIcon : Building2Icon,
|
|
242
|
+
act: { kind: 'go', href: `/${segment(owner.login)}` },
|
|
243
|
+
}));
|
|
244
|
+
const refs = (kind: Kind): readonly Row[] =>
|
|
245
|
+
place === undefined
|
|
246
|
+
? []
|
|
247
|
+
: (client.getQueryData(refNameList(place, kind).queryKey)?.pages ?? []).flatMap((page) =>
|
|
248
|
+
page.names.map((name): Row => ({
|
|
249
|
+
id: `${kind}:${name}`,
|
|
250
|
+
label: name,
|
|
251
|
+
note: kind === 'branches' ? 'Branch' : 'Tag',
|
|
252
|
+
icon: kind === 'branches' ? GitBranchIcon : TagIcon,
|
|
253
|
+
act: { kind: 'go', href: treeHref(place, name, '') },
|
|
254
|
+
})),
|
|
255
|
+
);
|
|
256
|
+
const jump = jumpOf(text, at.here, window.location.origin);
|
|
257
|
+
|
|
258
|
+
return [
|
|
259
|
+
{ heading: 'Go to', rows: jump === undefined ? [] : [jumpRow(jump)] },
|
|
260
|
+
{ heading: 'Recent', rows: bestOf(recent, wordsOf, text, resultsMost) },
|
|
261
|
+
{ heading: 'Pages', rows: bestOf(pages, wordsOf, text, resultsMost) },
|
|
262
|
+
{ heading: 'Repositories', rows: bestOf(repos, wordsOf, text, resultsMost) },
|
|
263
|
+
{ heading: 'Organizations', rows: bestOf(orgs, (row) => row.label, text, resultsMost) },
|
|
264
|
+
{ heading: 'Branches', rows: bestOf(refs('branches'), wordsOf, text, resultsMost) },
|
|
265
|
+
{ heading: 'Tags', rows: bestOf(refs('tags'), wordsOf, text, resultsMost) },
|
|
266
|
+
];
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
/** `@`: the viewer's own owners, then their orgs' members, read once typing stops. */
|
|
270
|
+
const usePeople = (at: PaletteAt, text: string, asking: boolean): readonly Group[] => {
|
|
271
|
+
const members = useQueries({
|
|
272
|
+
queries: at.orgs.map((org) => ({ ...orgMembers(org), enabled: asking })),
|
|
273
|
+
});
|
|
274
|
+
const owners = ownersOf(at).map((owner): Row => ({
|
|
275
|
+
id: `owner:${owner.login}`,
|
|
276
|
+
label: owner.login,
|
|
277
|
+
note: owner.kind === 'viewer' ? 'You' : 'Organization',
|
|
278
|
+
icon: owner.kind === 'viewer' ? UserIcon : Building2Icon,
|
|
279
|
+
act: { kind: 'go', href: `/${segment(owner.login)}` },
|
|
280
|
+
}));
|
|
281
|
+
const logins = [...new Set(members.flatMap((each) => each.data ?? []))].filter(
|
|
282
|
+
(login) => login !== at.viewer,
|
|
283
|
+
);
|
|
284
|
+
const people = logins.map((login): Row => ({
|
|
285
|
+
id: `person:${login}`,
|
|
286
|
+
label: login,
|
|
287
|
+
icon: UserIcon,
|
|
288
|
+
act: { kind: 'go', href: `/${segment(login)}` },
|
|
289
|
+
}));
|
|
290
|
+
const failed = members.filter((each) => each.isError);
|
|
291
|
+
const status: Status | undefined =
|
|
292
|
+
!asking || members.some((each) => each.isPending)
|
|
293
|
+
? at.orgs.length === 0
|
|
294
|
+
? undefined
|
|
295
|
+
: { kind: 'searching' }
|
|
296
|
+
: failed.length > 0
|
|
297
|
+
? {
|
|
298
|
+
kind: 'failed',
|
|
299
|
+
retry: () => {
|
|
300
|
+
if (asking) failed.forEach((each) => void each.refetch());
|
|
301
|
+
},
|
|
302
|
+
}
|
|
303
|
+
: undefined;
|
|
304
|
+
|
|
305
|
+
return [
|
|
306
|
+
{ heading: 'Owners', rows: bestOf(owners, (row) => row.label, text, resultsMost) },
|
|
307
|
+
{
|
|
308
|
+
heading: 'People',
|
|
309
|
+
rows: bestOf(people, (row) => row.label, text, resultsMost),
|
|
310
|
+
status,
|
|
311
|
+
},
|
|
312
|
+
];
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/** `#`: `#12` goes to that number, and other words search the page's repo once typing stops. */
|
|
316
|
+
const useIssues = (
|
|
317
|
+
at: PaletteAt,
|
|
318
|
+
text: string,
|
|
319
|
+
settled: string,
|
|
320
|
+
asking: boolean,
|
|
321
|
+
): readonly Group[] => {
|
|
322
|
+
const wanted = issueQueryOf(settled, at.here);
|
|
323
|
+
const typing = issueQueryOf(text, at.here);
|
|
324
|
+
const found = useQuery({ ...issueSearch(wanted ?? ''), enabled: asking && wanted !== undefined });
|
|
325
|
+
const number = numberJump(text, at.here);
|
|
326
|
+
|
|
327
|
+
const rows = (found.data?.items ?? []).map((item): Row => {
|
|
328
|
+
const where = `${item.owner}/${item.repo}#${item.number}`;
|
|
329
|
+
const href = `/${segment(item.owner)}/${segment(item.repo)}/${item.pull ? 'pull' : 'issues'}/${item.number}`;
|
|
330
|
+
|
|
331
|
+
return {
|
|
332
|
+
id: `issue:${where}`,
|
|
333
|
+
label: item.title,
|
|
334
|
+
note: where,
|
|
335
|
+
icon: item.pull ? GitPullRequestIcon : CircleDotIcon,
|
|
336
|
+
act: {
|
|
337
|
+
kind: 'go',
|
|
338
|
+
href,
|
|
339
|
+
keep: { kind: item.pull ? 'pull' : 'issue', label: item.title, note: where, href },
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
});
|
|
343
|
+
const status: Status | undefined =
|
|
344
|
+
typing === undefined
|
|
345
|
+
? text.trim() === '' || number !== undefined
|
|
346
|
+
? undefined
|
|
347
|
+
: { kind: 'hint', words: 'Open a repository first, or name one with repo:owner/name' }
|
|
348
|
+
: typing !== wanted || found.isFetching
|
|
349
|
+
? { kind: 'searching' }
|
|
350
|
+
: found.isError
|
|
351
|
+
? {
|
|
352
|
+
kind: 'failed',
|
|
353
|
+
retry: () => {
|
|
354
|
+
if (asking) void found.refetch();
|
|
355
|
+
},
|
|
356
|
+
}
|
|
357
|
+
: found.data?.incomplete === true
|
|
358
|
+
? { kind: 'incomplete' }
|
|
359
|
+
: undefined;
|
|
360
|
+
|
|
361
|
+
return [
|
|
362
|
+
{
|
|
363
|
+
heading: 'Go to',
|
|
364
|
+
rows: number === undefined ? [] : [targetRow('number', number, ArrowRightIcon)],
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
heading: 'Issues and pull requests',
|
|
368
|
+
rows: typing === wanted ? rows : [],
|
|
369
|
+
status,
|
|
370
|
+
},
|
|
371
|
+
];
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* `/`: the page's repo's files, from Go to file's own read of its default branch. Neither read
|
|
376
|
+
* retries by itself, as the palette's own don't: `enabled` can't stop a retry already waiting, so
|
|
377
|
+
* one would ask again while the palette closes, and a failure shows Retry at once instead. A
|
|
378
|
+
* query retries as the observer whose fetch runs says, so Go to file's own tree read keeps its
|
|
379
|
+
* retries.
|
|
380
|
+
*/
|
|
381
|
+
const useFiles = (at: PaletteAt, text: string, asking: boolean): readonly Group[] => {
|
|
382
|
+
const place = placeOf(at.here);
|
|
383
|
+
const branch = at.here.defaultBranch;
|
|
384
|
+
const head = useQuery({
|
|
385
|
+
...headCommit(place ?? { owner: '', repo: '' }, { kind: 'branch', name: branch ?? '' }),
|
|
386
|
+
enabled: asking && place !== undefined && branch !== undefined,
|
|
387
|
+
retry: false,
|
|
388
|
+
});
|
|
389
|
+
const tree = head.data?.tree;
|
|
390
|
+
const files = useQuery({
|
|
391
|
+
...allFiles(place ?? { owner: '', repo: '' }, tree ?? ''),
|
|
392
|
+
enabled: asking && place !== undefined && tree !== undefined,
|
|
393
|
+
retry: false,
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
if (place === undefined || branch === undefined) {
|
|
397
|
+
return [
|
|
398
|
+
{ heading: 'Files', rows: [], status: { kind: 'hint', words: 'Open a repository first' } },
|
|
399
|
+
];
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const failed = head.isError ? head : files.isError ? files : undefined;
|
|
403
|
+
const status: Status | undefined =
|
|
404
|
+
failed !== undefined
|
|
405
|
+
? {
|
|
406
|
+
kind: 'failed',
|
|
407
|
+
retry: () => {
|
|
408
|
+
if (asking) void failed.refetch();
|
|
409
|
+
},
|
|
410
|
+
}
|
|
411
|
+
: head.isPending || (tree !== undefined && files.isPending)
|
|
412
|
+
? { kind: 'searching' }
|
|
413
|
+
: files.data?.truncated === true
|
|
414
|
+
? { kind: 'incomplete' }
|
|
415
|
+
: undefined;
|
|
416
|
+
const paths = bestOf(files.data?.paths ?? [], (path) => path, text, resultsMost);
|
|
417
|
+
|
|
418
|
+
return [
|
|
419
|
+
{
|
|
420
|
+
heading: 'Files',
|
|
421
|
+
rows: paths.map((path): Row => ({
|
|
422
|
+
id: `file:${path}`,
|
|
423
|
+
label: path,
|
|
424
|
+
icon: FileIcon,
|
|
425
|
+
act: { kind: 'go', href: blobHref(place, branch, path) },
|
|
426
|
+
})),
|
|
427
|
+
status,
|
|
428
|
+
},
|
|
429
|
+
];
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
/** `?`: each symbol, which picking switches to. */
|
|
433
|
+
const helpRows = (switchTo: (typed: Typed) => void): readonly Row[] =>
|
|
434
|
+
symbols.map(({ symbol, finds }) => ({
|
|
435
|
+
id: `help:${symbol}`,
|
|
436
|
+
label: symbol,
|
|
437
|
+
note: finds,
|
|
438
|
+
icon: TerminalIcon,
|
|
439
|
+
act: { kind: 'run', run: () => switchTo({ symbol, text: '' }), stays: true },
|
|
440
|
+
}));
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* The groups for `typed`: with no mode, what's local; with one, its own. A mode that asks the
|
|
444
|
+
* drop-in asks only once typing has stopped for `typingWait`, and only for what was typed then.
|
|
445
|
+
* A palette no longer `shown`, whose input takes keys until its exit animation ends, asks nothing,
|
|
446
|
+
* and its retries ask nothing either.
|
|
447
|
+
*/
|
|
448
|
+
export const useGroups = (
|
|
449
|
+
at: PaletteAt,
|
|
450
|
+
typed: Typed,
|
|
451
|
+
commands: readonly Row[],
|
|
452
|
+
switchTo: (typed: Typed) => void,
|
|
453
|
+
shown: boolean,
|
|
454
|
+
): readonly Group[] => {
|
|
455
|
+
const settled = useSettled(typed.text) ?? '';
|
|
456
|
+
const people = usePeople(at, typed.text, shown && typed.symbol === '@');
|
|
457
|
+
const issues = useIssues(
|
|
458
|
+
at,
|
|
459
|
+
typed.symbol === '#' ? typed.text : '',
|
|
460
|
+
typed.symbol === '#' ? settled : '',
|
|
461
|
+
shown,
|
|
462
|
+
);
|
|
463
|
+
const files = useFiles(at, typed.text, shown && typed.symbol === '/');
|
|
464
|
+
const found = useFound(at, typed.symbol === undefined ? typed.text : '');
|
|
465
|
+
|
|
466
|
+
switch (typed.symbol) {
|
|
467
|
+
case '@':
|
|
468
|
+
return people;
|
|
469
|
+
case '#':
|
|
470
|
+
return issues;
|
|
471
|
+
case '/':
|
|
472
|
+
return files;
|
|
473
|
+
case '>':
|
|
474
|
+
return [
|
|
475
|
+
{
|
|
476
|
+
heading: 'Commands',
|
|
477
|
+
rows: bestOf(commands, (row) => row.label, typed.text, commands.length),
|
|
478
|
+
},
|
|
479
|
+
];
|
|
480
|
+
case '?':
|
|
481
|
+
return [
|
|
482
|
+
{ heading: 'Modes', rows: bestOf(helpRows(switchTo), wordsOf, typed.text, symbols.length) },
|
|
483
|
+
];
|
|
484
|
+
case undefined:
|
|
485
|
+
return found;
|
|
486
|
+
}
|
|
487
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { queryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { github } from '../clients/clients.ts';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What the palette asks the drop-in for, once typing stops: one request a mode, each with its
|
|
8
|
+
* `signal`, so the query cache aborts it when the next one takes its place. Answers are kept for
|
|
9
|
+
* the session, by what was asked, so typing back to an earlier query reads nothing.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** The most results a mode shows from the drop-in, and asks it for. */
|
|
13
|
+
export const resultsMost = 8;
|
|
14
|
+
|
|
15
|
+
/** How long typing must stop before a mode asks the drop-in. */
|
|
16
|
+
export const typingWait = 150;
|
|
17
|
+
|
|
18
|
+
/** The key every read of the palette's own starts with, which closing it cancels. */
|
|
19
|
+
export const paletteReads = ['palette'] as const;
|
|
20
|
+
|
|
21
|
+
/** An answer kept for the session: a search typed again shows at once. */
|
|
22
|
+
const forTheSession = { staleTime: Infinity, gcTime: Infinity, retry: false } as const;
|
|
23
|
+
|
|
24
|
+
/** An issue or pull request a search found. */
|
|
25
|
+
export interface FoundIssue {
|
|
26
|
+
readonly owner: string;
|
|
27
|
+
readonly repo: string;
|
|
28
|
+
readonly number: number;
|
|
29
|
+
readonly title: string;
|
|
30
|
+
readonly pull: boolean;
|
|
31
|
+
readonly open: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** What a search answered: its results, and whether it scanned only some of what might match. */
|
|
35
|
+
export interface Found<T> {
|
|
36
|
+
readonly items: readonly T[];
|
|
37
|
+
readonly incomplete: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A search item's repo, from the last two segments of its `repository_url`. */
|
|
41
|
+
const repoOfUrl = (url: string) => {
|
|
42
|
+
const [owner = '', repo = ''] = url.split('/').slice(-2).map(decodeURIComponent);
|
|
43
|
+
|
|
44
|
+
return { owner, repo };
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** The issues and pull requests `GET /search/issues` finds for `q`, at most `resultsMost`. */
|
|
48
|
+
export const issueSearch = (q: string) =>
|
|
49
|
+
queryOptions({
|
|
50
|
+
queryKey: [...paletteReads, 'issues', q],
|
|
51
|
+
queryFn: async ({ signal }): Promise<Found<FoundIssue>> => {
|
|
52
|
+
const answer = await github.GET('/search/issues', {
|
|
53
|
+
params: { query: { q, per_page: resultsMost } },
|
|
54
|
+
signal,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (answer.data === undefined) {
|
|
58
|
+
throw new Error(`The search didn't load (${answer.response.status})`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
items: answer.data.items.map((item) => ({
|
|
63
|
+
...repoOfUrl(item.repository_url),
|
|
64
|
+
number: item.number,
|
|
65
|
+
title: item.title,
|
|
66
|
+
pull: item.pull_request !== undefined,
|
|
67
|
+
open: item.state === 'open',
|
|
68
|
+
})),
|
|
69
|
+
incomplete: answer.data.incomplete_results,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
...forTheSession,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The logins of `org`'s members, its first 100, which `@` matches in the browser until the
|
|
77
|
+
* drop-in serves `GET /search/users` (Q778).
|
|
78
|
+
*/
|
|
79
|
+
export const orgMembers = (org: string) =>
|
|
80
|
+
queryOptions({
|
|
81
|
+
queryKey: [...paletteReads, 'members', org],
|
|
82
|
+
queryFn: async ({ signal }): Promise<readonly string[]> => {
|
|
83
|
+
const answer = await github.GET('/orgs/{org}/members', {
|
|
84
|
+
params: { path: { org }, query: { per_page: 100 } },
|
|
85
|
+
signal,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (answer.data === undefined) {
|
|
89
|
+
throw new Error(`${org}'s members didn't load (${answer.response.status})`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return answer.data.map((member) => member.login);
|
|
93
|
+
},
|
|
94
|
+
...forTheSession,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
/** `value` once it has stayed the same for `typingWait`. */
|
|
98
|
+
export const useSettled = (value: string | undefined): string | undefined => {
|
|
99
|
+
const [settled, setSettled] = useState(value);
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
const timer = setTimeout(() => setSettled(value), typingWait);
|
|
102
|
+
|
|
103
|
+
return () => clearTimeout(timer);
|
|
104
|
+
}, [value]);
|
|
105
|
+
|
|
106
|
+
return settled;
|
|
107
|
+
};
|