ref0-git 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +122 -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 +547 -0
- package/app/apps/github/src/palette/recent.ts +116 -0
- package/app/apps/github/src/palette/rows.tsx +455 -0
- package/app/apps/github/src/palette/server.ts +104 -0
- package/app/apps/github/src/palette/targets.ts +306 -0
- package/app/apps/github/src/policy.ts +600 -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 +538 -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 +48 -0
- package/dist/cli/helpers.mjs +51 -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 +79 -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 +75 -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 +205 -0
- package/dist/init/node-app.mjs +189 -0
- package/dist/init/node.mjs +458 -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 +383 -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,440 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type InfiniteData,
|
|
3
|
+
infiniteQueryOptions,
|
|
4
|
+
type QueryClient,
|
|
5
|
+
queryOptions,
|
|
6
|
+
useInfiniteQuery,
|
|
7
|
+
} from '@tanstack/react-query';
|
|
8
|
+
import { notFound } from '@tanstack/react-router';
|
|
9
|
+
import { flow } from 'effect/Function';
|
|
10
|
+
import * as Option from 'effect/Option';
|
|
11
|
+
import * as Schema from 'effect/Schema';
|
|
12
|
+
|
|
13
|
+
import { cached, readPagesAhead } from '../clients/cached.ts';
|
|
14
|
+
import { github } from '../clients/clients.ts';
|
|
15
|
+
import { ownerProblem } from '../names/owners.ts';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* An owner's repositories, read through the drop-in's lists, which sort them and page by the
|
|
19
|
+
* cursor their `Link` names (Q391). The drop-in serves no `/search/repositories`, so search and
|
|
20
|
+
* language are the browser's, over every page, up to `maxFiltered` rows. The viewer's own list
|
|
21
|
+
* filters visibility with `visibility`, beside `affiliation=owner` (GitHub refuses either beside
|
|
22
|
+
* `type`), and an org's every type with `type`. A person's list reads neither, so the browser
|
|
23
|
+
* filters it, as it does sources and forks on the viewer's.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** A row of a repository list, in the fields every list GitHub serves carries. */
|
|
27
|
+
export interface RepoRow {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly full_name: string;
|
|
30
|
+
readonly private: boolean;
|
|
31
|
+
readonly description: string | null;
|
|
32
|
+
readonly fork: boolean;
|
|
33
|
+
readonly archived: boolean;
|
|
34
|
+
readonly updated_at: string | null;
|
|
35
|
+
/** The language the drop-in's job found most of, or `null` before it looked or when none. */
|
|
36
|
+
readonly language: string | null;
|
|
37
|
+
/** The license's SPDX ID, such as `MIT`, or `null` when it found none, or one it can't name. */
|
|
38
|
+
readonly license: string | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Whose repositories a page lists, as the route found its owner. */
|
|
42
|
+
export type Owner =
|
|
43
|
+
| { readonly kind: 'viewer'; readonly login: string }
|
|
44
|
+
| { readonly kind: 'org'; readonly login: string }
|
|
45
|
+
| { readonly kind: 'user'; readonly login: string };
|
|
46
|
+
|
|
47
|
+
/** Which repositories a list asks the drop-in for, as GitHub's lists filter them. */
|
|
48
|
+
type Visibility = 'all' | 'public' | 'private';
|
|
49
|
+
|
|
50
|
+
const RepoType = Schema.Literals(['all', 'public', 'private', 'sources', 'forks']);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Which repositories a list keeps, as GitHub's Type menu names them: by visibility, or sources
|
|
54
|
+
* and forks, which the browser picks out of the pages loaded.
|
|
55
|
+
*/
|
|
56
|
+
export type RepoType = typeof RepoType.Type;
|
|
57
|
+
|
|
58
|
+
/** The visibility the drop-in filters for `type`: none for sources and forks. */
|
|
59
|
+
const visibilityOf = (type: RepoType): Visibility =>
|
|
60
|
+
type === 'public' || type === 'private' ? type : 'all';
|
|
61
|
+
|
|
62
|
+
const RepoSort = Schema.Literals(['updated', 'name']);
|
|
63
|
+
|
|
64
|
+
/** How a list is ordered: GitHub's Last updated, or by name. */
|
|
65
|
+
export type RepoSort = typeof RepoSort.Type;
|
|
66
|
+
|
|
67
|
+
/** GitHub's most a page holds. */
|
|
68
|
+
export const perPage = 100;
|
|
69
|
+
|
|
70
|
+
/** One of an owner's lookups, refused for any reason but a 404: the page can't say who it is. */
|
|
71
|
+
const lookupFailed = (status: number) => new Error(`The owner didn't load (${status})`);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The owner the URL names, as the drop-in knows it, or `undefined` when no one has that login. An
|
|
75
|
+
* org comes first: the starter's people answer for every login.
|
|
76
|
+
*/
|
|
77
|
+
export const ownerNamed = async (
|
|
78
|
+
login: string,
|
|
79
|
+
viewer: string | undefined,
|
|
80
|
+
): Promise<Owner | undefined> => {
|
|
81
|
+
if (viewer !== undefined && login.toLowerCase() === viewer.toLowerCase()) {
|
|
82
|
+
return { kind: 'viewer', login: viewer };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const org = await github.GET('/orgs/{org}', { params: { path: { org: login } } });
|
|
86
|
+
if (org.data !== undefined) return { kind: 'org', login: org.data.login };
|
|
87
|
+
|
|
88
|
+
if (org.response.status !== 404) throw lookupFailed(org.response.status);
|
|
89
|
+
|
|
90
|
+
const user = await github.GET('/users/{username}', { params: { path: { username: login } } });
|
|
91
|
+
if (user.data !== undefined) return { kind: 'user', login: user.data.login };
|
|
92
|
+
|
|
93
|
+
if (user.response.status !== 404) throw lookupFailed(user.response.status);
|
|
94
|
+
|
|
95
|
+
return undefined;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The owner `login` names, for `viewer`: read once by the route that names it, before its page
|
|
100
|
+
* draws, and kept, so the shell's owner, switcher and lists all read the one answer. `null` for no
|
|
101
|
+
* one.
|
|
102
|
+
*/
|
|
103
|
+
export const ownerAt = (login: string, viewer: string | undefined) =>
|
|
104
|
+
queryOptions({
|
|
105
|
+
queryKey: ['owner', login.toLowerCase(), viewer ?? null],
|
|
106
|
+
queryFn: async () => (await ownerNamed(login, viewer)) ?? null,
|
|
107
|
+
staleTime: 5 * 60_000,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Whether `viewer` belongs to `org`, by GitHub's membership check: 204 for a member, and for
|
|
112
|
+
* anyone else 404, or 302 to the public check, which a browser follows to its 404. It reads the
|
|
113
|
+
* one membership, so an org past the 1,000 the viewer's own list holds still answers.
|
|
114
|
+
*/
|
|
115
|
+
export const viewerBelongs = async (org: string, viewer: string): Promise<boolean> => {
|
|
116
|
+
const checked = await github.GET('/orgs/{org}/members/{username}', {
|
|
117
|
+
params: { path: { org, username: viewer } },
|
|
118
|
+
});
|
|
119
|
+
const { status } = checked.response;
|
|
120
|
+
if (status === 204) return true;
|
|
121
|
+
|
|
122
|
+
if (status === 302 || status === 404) return false;
|
|
123
|
+
|
|
124
|
+
throw lookupFailed(status);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** The signed-in viewer a page draws for, as the root route's load read them. */
|
|
128
|
+
export interface PageViewer {
|
|
129
|
+
readonly login: string;
|
|
130
|
+
/** The orgs the viewer belongs to: the first 1,000 alone. */
|
|
131
|
+
readonly orgs: readonly string[];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Whether `viewer` belongs to `org`: its membership check, or, when the check fails rather than
|
|
136
|
+
* answering, the orgs the viewer holds, as the app decided before it had the check. Only a failure
|
|
137
|
+
* falls back: a 404 or 302 still says not a member. The server decides every create, so the
|
|
138
|
+
* fallback offers nothing the server would let no one do.
|
|
139
|
+
*/
|
|
140
|
+
const belongsOr = (org: string, viewer: PageViewer): Promise<boolean> =>
|
|
141
|
+
viewerBelongs(org, viewer.login).catch(() => viewer.orgs.includes(org));
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The org New repository starts under: the one `?owner=` names, when the viewer belongs to it, by
|
|
145
|
+
* the orgs they hold or, past the 1,000 those list, by its membership check. Anything else starts
|
|
146
|
+
* under the viewer.
|
|
147
|
+
*/
|
|
148
|
+
export const newUnderOrg = async (
|
|
149
|
+
owner: string | undefined,
|
|
150
|
+
viewer: PageViewer,
|
|
151
|
+
): Promise<string | undefined> => {
|
|
152
|
+
if (owner === undefined || owner.toLowerCase() === viewer.login.toLowerCase()) return undefined;
|
|
153
|
+
|
|
154
|
+
if (viewer.orgs.includes(owner)) return owner;
|
|
155
|
+
|
|
156
|
+
return (await belongsOr(owner, viewer)) ? owner : undefined;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* What an owner's page loads before it draws: the owner, or `undefined` when the URL names one of
|
|
161
|
+
* the app's own pages or no one, and whether the viewer belongs to it. For someone signed in, whom
|
|
162
|
+
* alone it shows, it reads the list's first page too, so the server draws the rows, not a skeleton
|
|
163
|
+
* the browser swaps out. Whether the viewer belongs to an org is its membership check, not the
|
|
164
|
+
* viewer's orgs, which hold the first 1,000 alone, unless the check fails.
|
|
165
|
+
*/
|
|
166
|
+
export const ownerPage = async (
|
|
167
|
+
login: string,
|
|
168
|
+
viewer: PageViewer | null,
|
|
169
|
+
client: QueryClient,
|
|
170
|
+
filter: RepoFilter,
|
|
171
|
+
): Promise<{ readonly owner: Owner; readonly member: boolean } | undefined> => {
|
|
172
|
+
if (ownerProblem(login) !== undefined) return undefined;
|
|
173
|
+
|
|
174
|
+
const owner = await cached(client, ownerAt(login, viewer?.login));
|
|
175
|
+
if (owner === null) return undefined;
|
|
176
|
+
|
|
177
|
+
if (viewer === null) return { owner, member: false };
|
|
178
|
+
|
|
179
|
+
const [member] = await Promise.all([
|
|
180
|
+
owner.kind === 'org' ? belongsOr(owner.login, viewer) : false,
|
|
181
|
+
readPagesAhead(client, repoList(owner, filter)),
|
|
182
|
+
]);
|
|
183
|
+
|
|
184
|
+
return { owner, member };
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/** What an owner's page loads by: its URL's query, read. */
|
|
188
|
+
export const ownerLoaderDeps = ({ search }: { readonly search: RepoSearch }) => search;
|
|
189
|
+
|
|
190
|
+
/** What an owner's page loader reads: the URL's owner and query, and the root's viewer and cache. */
|
|
191
|
+
export interface OwnerLoad {
|
|
192
|
+
readonly params: { readonly owner: string };
|
|
193
|
+
readonly context: { readonly viewer: PageViewer | null; readonly queryClient: QueryClient };
|
|
194
|
+
readonly deps: RepoSearch;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** An owner's page's loader: `ownerPage`, or not found for an owner no one has. */
|
|
198
|
+
export const ownerLoader = async ({ params, context, deps }: OwnerLoad) => {
|
|
199
|
+
const loaded = await ownerPage(params.owner, context.viewer, context.queryClient, filterOf(deps));
|
|
200
|
+
if (loaded === undefined) throw notFound();
|
|
201
|
+
|
|
202
|
+
return loaded;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/** What New repository loads by: the owner its query names. */
|
|
206
|
+
export const newLoaderDeps = ({
|
|
207
|
+
search,
|
|
208
|
+
}: {
|
|
209
|
+
readonly search: { readonly owner?: string | undefined };
|
|
210
|
+
}) => ({
|
|
211
|
+
owner: search.owner,
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
/** What New repository's loader reads: the owner its query names, and the root's viewer. */
|
|
215
|
+
export interface NewLoad {
|
|
216
|
+
readonly context: { readonly viewer: PageViewer | null };
|
|
217
|
+
readonly deps: { readonly owner: string | undefined };
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** New repository's loader: the org the form starts under, by `newUnderOrg`, or none. */
|
|
221
|
+
export const newLoader = async ({ context, deps }: NewLoad) => ({
|
|
222
|
+
org: context.viewer === null ? undefined : await newUnderOrg(deps.owner, context.viewer),
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* What the drop-in picks out of `owner`'s list for `type`: an org's list takes every type, as
|
|
227
|
+
* GitHub's does, the viewer's its visibility, beside `affiliation=owner`, and a person's none.
|
|
228
|
+
*/
|
|
229
|
+
const serverType = (owner: Owner, type: RepoType): RepoType => {
|
|
230
|
+
switch (owner.kind) {
|
|
231
|
+
case 'org':
|
|
232
|
+
return type;
|
|
233
|
+
case 'viewer':
|
|
234
|
+
return visibilityOf(type);
|
|
235
|
+
case 'user':
|
|
236
|
+
return 'all';
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/** The most rows a list loads to filter in the browser, as the drop-in's count reaches (#449). */
|
|
241
|
+
export const maxFiltered = 1000;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Whether `filter` keeps rows the drop-in can't pick out of `owner`'s list: a search, a language,
|
|
245
|
+
* or a type its list doesn't take. The list then loads every page, up to `maxFiltered` rows,
|
|
246
|
+
* before it filters them, so a match on a later page isn't missed.
|
|
247
|
+
*/
|
|
248
|
+
export const filtersInBrowser = (owner: Owner, filter: RepoFilter) =>
|
|
249
|
+
filter.search.trim() !== '' ||
|
|
250
|
+
filter.language !== '' ||
|
|
251
|
+
serverType(owner, filter.type) !== filter.type;
|
|
252
|
+
|
|
253
|
+
/** GitHub's `sort` and `direction` for each order the list offers. */
|
|
254
|
+
const orders = {
|
|
255
|
+
updated: { sort: 'updated', direction: 'desc' },
|
|
256
|
+
name: { sort: 'full_name', direction: 'asc' },
|
|
257
|
+
} as const satisfies Record<RepoSort, { readonly sort: string; readonly direction: string }>;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* The cursor a list's `Link: <…>; rel="next"` names in `param`, `after` or a search's `page`, or
|
|
261
|
+
* `undefined` on its last page.
|
|
262
|
+
*/
|
|
263
|
+
export const nextCursor = (link: string | null, param: 'after' | 'page' = 'after') => {
|
|
264
|
+
const next = link?.split(',').find((part) => /;\s*rel="next"/.test(part));
|
|
265
|
+
const url = next?.match(/<([^>]+)>/)?.[1];
|
|
266
|
+
|
|
267
|
+
return url === undefined ? undefined : (URL.parse(url)?.searchParams.get(param) ?? undefined);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
/** A page of a list, and the cursor of the one after it. */
|
|
271
|
+
export interface RepoPage {
|
|
272
|
+
readonly repos: readonly RepoRow[];
|
|
273
|
+
readonly next: string | undefined;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** What a list asks the drop-in for: its order, and the type it filters. */
|
|
277
|
+
interface RepoQuery {
|
|
278
|
+
readonly sort: RepoSort;
|
|
279
|
+
readonly type: RepoType;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** One page of `owner`'s repositories in `query`'s order, from `after`, or the first. */
|
|
283
|
+
const answerOf = async (owner: Owner, query: RepoQuery, after: string | undefined) => {
|
|
284
|
+
// `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it.
|
|
285
|
+
const paging = { per_page: perPage, after, ...orders[query.sort] };
|
|
286
|
+
|
|
287
|
+
switch (owner.kind) {
|
|
288
|
+
case 'org':
|
|
289
|
+
return github.GET('/orgs/{org}/repos', {
|
|
290
|
+
params: { path: { org: owner.login }, query: { ...paging, type: query.type } },
|
|
291
|
+
});
|
|
292
|
+
case 'user':
|
|
293
|
+
return github.GET('/users/{username}/repos', {
|
|
294
|
+
params: { path: { username: owner.login }, query: { ...paging } },
|
|
295
|
+
});
|
|
296
|
+
case 'viewer':
|
|
297
|
+
return github.GET('/user/repos', {
|
|
298
|
+
params: {
|
|
299
|
+
query: { ...paging, affiliation: 'owner', visibility: visibilityOf(query.type) },
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
const repoPage = async (
|
|
306
|
+
owner: Owner,
|
|
307
|
+
query: RepoQuery,
|
|
308
|
+
after: string | undefined,
|
|
309
|
+
): Promise<RepoPage> => {
|
|
310
|
+
const answer = await answerOf(owner, query, after);
|
|
311
|
+
if (answer.data === undefined)
|
|
312
|
+
throw new Error(`The repositories didn't load (${answer.response.status})`);
|
|
313
|
+
|
|
314
|
+
const repos = answer.data.map((repo): RepoRow => ({
|
|
315
|
+
name: repo.name,
|
|
316
|
+
full_name: repo.full_name,
|
|
317
|
+
private: repo.private,
|
|
318
|
+
description: repo.description,
|
|
319
|
+
fork: repo.fork,
|
|
320
|
+
archived: repo.archived ?? false,
|
|
321
|
+
updated_at: repo.updated_at ?? null,
|
|
322
|
+
language: repo.language ?? null,
|
|
323
|
+
license: repo.license?.spdx_id ?? null,
|
|
324
|
+
}));
|
|
325
|
+
|
|
326
|
+
return { repos, next: nextCursor(answer.response.headers.get('link')) };
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
/** A list's first page, which names no cursor. */
|
|
330
|
+
const firstPage: string | undefined = undefined;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* `owner`'s repositories in `filter`'s order, a page at a time, as the list scrolls on, with the
|
|
334
|
+
* drop-in filtering what its list takes: a route's loader reads the first page before it draws.
|
|
335
|
+
*/
|
|
336
|
+
export const repoList = (owner: Owner, filter: RepoFilter) => {
|
|
337
|
+
const query: RepoQuery = { sort: filter.sort, type: serverType(owner, filter.type) };
|
|
338
|
+
|
|
339
|
+
// Its pages' param named, as the loaders' `readPagesAhead` reads it, where the default is `unknown`.
|
|
340
|
+
return infiniteQueryOptions<
|
|
341
|
+
RepoPage,
|
|
342
|
+
Error,
|
|
343
|
+
InfiniteData<RepoPage, string | undefined>,
|
|
344
|
+
string[],
|
|
345
|
+
string | undefined
|
|
346
|
+
>({
|
|
347
|
+
queryKey: ['repos', owner.kind, owner.login, query.sort, query.type],
|
|
348
|
+
queryFn: ({ pageParam }) => repoPage(owner, query, pageParam),
|
|
349
|
+
initialPageParam: firstPage,
|
|
350
|
+
getNextPageParam: (last: RepoPage) => last.next,
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* `repoList` as a list draws it. A new order or type keeps the same owner's old rows showing
|
|
356
|
+
* until the new ones come; a new owner shows none: the route keeps the page mounted when only
|
|
357
|
+
* `$owner` changes.
|
|
358
|
+
*/
|
|
359
|
+
export const useRepos = (owner: Owner, filter: RepoFilter) =>
|
|
360
|
+
useInfiniteQuery({
|
|
361
|
+
...repoList(owner, filter),
|
|
362
|
+
placeholderData: (previous, previousQuery) =>
|
|
363
|
+
previousQuery?.queryKey[1] === owner.kind && previousQuery.queryKey[2] === owner.login
|
|
364
|
+
? previous
|
|
365
|
+
: undefined,
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
/** What a list shows of the repositories it has loaded. */
|
|
369
|
+
export interface RepoFilter {
|
|
370
|
+
readonly search: string;
|
|
371
|
+
readonly type: RepoType;
|
|
372
|
+
/** The language its rows are in, or `''` for any. */
|
|
373
|
+
readonly language: string;
|
|
374
|
+
readonly sort: RepoSort;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** A list's URL query, as the page writes it, in GitHub's words: each part left out while it's the default. */
|
|
378
|
+
const RepoSearch = Schema.Struct({
|
|
379
|
+
q: Schema.optional(Schema.String),
|
|
380
|
+
type: Schema.optional(RepoType),
|
|
381
|
+
language: Schema.optional(Schema.String),
|
|
382
|
+
sort: Schema.optional(RepoSort),
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
export type RepoSearch = typeof RepoSearch.Type;
|
|
386
|
+
|
|
387
|
+
/** A list's URL query, read: one it can't read is the defaults'. */
|
|
388
|
+
export const readSearch = flow(
|
|
389
|
+
Schema.decodeUnknownOption(RepoSearch),
|
|
390
|
+
Option.getOrElse((): RepoSearch => ({})),
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
/** The filter a list's URL query names. */
|
|
394
|
+
export const filterOf = (search: RepoSearch): RepoFilter => ({
|
|
395
|
+
search: search.q ?? '',
|
|
396
|
+
type: search.type ?? 'all',
|
|
397
|
+
language: search.language ?? '',
|
|
398
|
+
sort: search.sort ?? 'updated',
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
/** The URL query for `filter`; the router leaves out each default's `undefined`, so a plain list has a plain URL. */
|
|
402
|
+
export const searchOf = (filter: RepoFilter): RepoSearch => ({
|
|
403
|
+
q: filter.search === '' ? undefined : filter.search,
|
|
404
|
+
type: filter.type === 'all' ? undefined : filter.type,
|
|
405
|
+
language: filter.language === '' ? undefined : filter.language,
|
|
406
|
+
sort: filter.sort === 'updated' ? undefined : filter.sort,
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
/** Whether `repo` is of `type`: its visibility, or a source or a fork. */
|
|
410
|
+
const ofType = (repo: RepoRow, type: RepoType) => {
|
|
411
|
+
switch (type) {
|
|
412
|
+
case 'all':
|
|
413
|
+
return true;
|
|
414
|
+
case 'public':
|
|
415
|
+
case 'private':
|
|
416
|
+
return repo.private === (type === 'private');
|
|
417
|
+
case 'sources':
|
|
418
|
+
return !repo.fork;
|
|
419
|
+
case 'forks':
|
|
420
|
+
return repo.fork;
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
/** The loaded `repos` `filter`'s search, type and language keep, in the drop-in's order. */
|
|
425
|
+
export const shownRepos = (repos: readonly RepoRow[], filter: RepoFilter) => {
|
|
426
|
+
const words = filter.search.trim().toLowerCase();
|
|
427
|
+
|
|
428
|
+
return repos.filter(
|
|
429
|
+
(repo) =>
|
|
430
|
+
ofType(repo, filter.type) &&
|
|
431
|
+
(filter.language === '' || repo.language === filter.language) &&
|
|
432
|
+
repo.name.toLowerCase().includes(words),
|
|
433
|
+
);
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
/** The languages the loaded `repos` are in, by name, for the Language menu. */
|
|
437
|
+
export const languagesOf = (repos: readonly RepoRow[]) =>
|
|
438
|
+
[...new Set(repos.flatMap((repo) => (repo.language === null ? [] : [repo.language])))].sort(
|
|
439
|
+
(a, b) => a.localeCompare(b),
|
|
440
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
const MOBILE_BREAKPOINT = 768
|
|
4
|
+
|
|
5
|
+
export function useIsMobile() {
|
|
6
|
+
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
|
|
7
|
+
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
|
|
10
|
+
const onChange = () => {
|
|
11
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
|
12
|
+
}
|
|
13
|
+
mql.addEventListener("change", onChange)
|
|
14
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
|
15
|
+
return () => mql.removeEventListener("change", onChange)
|
|
16
|
+
}, [])
|
|
17
|
+
|
|
18
|
+
return !!isMobile
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { queryOptions, type QueryClient } from '@tanstack/react-query';
|
|
2
|
+
|
|
3
|
+
import { cached } from '../clients/cached.ts';
|
|
4
|
+
import { viewing } from '../signin/viewer.ts';
|
|
5
|
+
|
|
6
|
+
/** How long a navigation trusts the viewer before it refreshes it behind. */
|
|
7
|
+
export const viewerFresh = 60_000;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Who the page is for, read once a page load and kept, so a navigation draws without asking the
|
|
11
|
+
* server first (F10). Past a minute, a navigation refreshes it behind, so an org made in another
|
|
12
|
+
* tab shows. A sign-in, a sign-up and a sign-out each load a new page, which reads it again.
|
|
13
|
+
*/
|
|
14
|
+
export const viewerQuery = queryOptions({
|
|
15
|
+
queryKey: ['viewing'],
|
|
16
|
+
queryFn: () => viewing(),
|
|
17
|
+
staleTime: viewerFresh,
|
|
18
|
+
gcTime: Number.POSITIVE_INFINITY,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The viewer, as the root route's context gives it to every page. A sign-in that ended is said
|
|
23
|
+
* once, as the server says it once: the page that reads it keeps a visitor whose sign-in didn't
|
|
24
|
+
* end, so the next page doesn't say it again. On the server too, since the browser takes a page
|
|
25
|
+
* load's context from the server's and runs this again only on its next navigation.
|
|
26
|
+
*/
|
|
27
|
+
export const viewerOf = async (client: QueryClient) => {
|
|
28
|
+
const read = await cached(client, viewerQuery);
|
|
29
|
+
if (read.ended) client.setQueryData(viewerQuery.queryKey, { ...read, ended: false });
|
|
30
|
+
|
|
31
|
+
return read;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Forgets the viewer, so the next navigation asks the server again: once a session ends, as
|
|
36
|
+
* Git refused its token, or once the viewer's orgs change.
|
|
37
|
+
*/
|
|
38
|
+
export const forgetViewer = (client: QueryClient) =>
|
|
39
|
+
client.removeQueries({ queryKey: viewerQuery.queryKey, exact: true });
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { queryOptions } from '@tanstack/react-query';
|
|
2
|
+
|
|
3
|
+
import { github } from '../clients/clients.ts';
|
|
4
|
+
import { failure } from '../hooks/answers.ts';
|
|
5
|
+
import { nextCursor } from '../hooks/repos.ts';
|
|
6
|
+
import { inboxListKey } from './threads.ts';
|
|
7
|
+
|
|
8
|
+
/** GitHub's largest page of notifications: the most unread threads one read counts. */
|
|
9
|
+
export const countedMost = 50;
|
|
10
|
+
|
|
11
|
+
/** How often the count checks, in seconds, when the server names no interval. */
|
|
12
|
+
const pollSeconds = 60;
|
|
13
|
+
|
|
14
|
+
/** The viewer's unread threads, as the sidebar's Inbox row counts them. */
|
|
15
|
+
export interface InboxCount {
|
|
16
|
+
/** The unread threads on the first page, at most `countedMost`. */
|
|
17
|
+
readonly count: number;
|
|
18
|
+
/** Whether more are unread past them, which the row shows as `50+`. */
|
|
19
|
+
readonly more: boolean;
|
|
20
|
+
/** The answer's `Last-Modified`, which the next check sends as `If-Modified-Since`. */
|
|
21
|
+
readonly modified: string | undefined;
|
|
22
|
+
/** How long the server asks a client to wait between checks, from its `X-Poll-Interval`. */
|
|
23
|
+
readonly pollMs: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The poll interval an answer names, in milliseconds: GitHub's 60 seconds when it names none. */
|
|
27
|
+
const pollMsOf = (headers: Headers) => {
|
|
28
|
+
const seconds = Number(headers.get('x-poll-interval'));
|
|
29
|
+
|
|
30
|
+
return (Number.isSafeInteger(seconds) && seconds > 0 ? seconds : pollSeconds) * 1000;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The viewer's unread count, checked every `X-Poll-Interval` and when the tab gets focus, with
|
|
35
|
+
* `If-Modified-Since` from the last answer. A `304` keeps the count it has, the same object, so
|
|
36
|
+
* nothing redraws and no list reads again. Any other answer to a held copy reads the inbox's lists
|
|
37
|
+
* again, so an open Inbox page shows what came, its `Last-Modified` moved or not.
|
|
38
|
+
*/
|
|
39
|
+
export const inboxCount = queryOptions({
|
|
40
|
+
queryKey: ['inbox', 'count'],
|
|
41
|
+
queryFn: async ({ client, queryKey }): Promise<InboxCount> => {
|
|
42
|
+
const held = client.getQueryData<InboxCount>(queryKey);
|
|
43
|
+
const answer = await github.GET('/notifications', {
|
|
44
|
+
params: { query: { per_page: countedMost } },
|
|
45
|
+
headers: held?.modified === undefined ? {} : { 'if-modified-since': held.modified },
|
|
46
|
+
});
|
|
47
|
+
if (answer.response.status === 304 && held !== undefined) return held;
|
|
48
|
+
|
|
49
|
+
if (answer.data === undefined) throw failure("The inbox's count didn't load", answer);
|
|
50
|
+
|
|
51
|
+
const { headers } = answer.response;
|
|
52
|
+
const counted: InboxCount = {
|
|
53
|
+
count: answer.data.filter((thread) => thread.unread).length,
|
|
54
|
+
more: nextCursor(headers.get('link')) !== undefined,
|
|
55
|
+
modified: headers.get('last-modified') ?? undefined,
|
|
56
|
+
pollMs: pollMsOf(headers),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// A 200 to the copy's If-Modified-Since is a change, even under the same Last-Modified: a
|
|
60
|
+
// change in the second that copy names keeps it, since HTTP's dates hold whole seconds.
|
|
61
|
+
if (held !== undefined && (held.modified !== undefined || counted.modified !== undefined)) {
|
|
62
|
+
await client.invalidateQueries({ queryKey: inboxListKey });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return counted;
|
|
66
|
+
},
|
|
67
|
+
refetchInterval: (query) => query.state.data?.pollMs ?? pollSeconds * 1000,
|
|
68
|
+
refetchOnWindowFocus: 'always',
|
|
69
|
+
retry: false,
|
|
70
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { InboxIcon } from 'lucide-react';
|
|
3
|
+
|
|
4
|
+
import { Go } from '../code/controls.tsx';
|
|
5
|
+
import { Count } from '../components/count.tsx';
|
|
6
|
+
import { HotkeyHint, Keys, hotkeys } from '../components/hotkeys/hotkeys.tsx';
|
|
7
|
+
import {
|
|
8
|
+
SidebarMenu,
|
|
9
|
+
SidebarMenuBadge,
|
|
10
|
+
SidebarMenuButton,
|
|
11
|
+
SidebarMenuItem,
|
|
12
|
+
} from '../components/ui/sidebar.tsx';
|
|
13
|
+
import { inboxCount } from './count.ts';
|
|
14
|
+
|
|
15
|
+
/** The Inbox page's own path. */
|
|
16
|
+
export const inboxPath = '/notifications';
|
|
17
|
+
|
|
18
|
+
/** Whether `path` is one of the Inbox's pages. */
|
|
19
|
+
export const inInbox = (path: string) =>
|
|
20
|
+
path === inboxPath || path.startsWith(`${inboxPath}?`) || path.startsWith(`${inboxPath}/`);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The sidebar's Inbox row, under the search input, for a signed-in viewer: it leads to the Inbox,
|
|
24
|
+
* as `g n` does, and shows the unread count at its end, where its keys show while ⌘ is held. A
|
|
25
|
+
* count of none, one that hasn't come, or one that failed, leaves the end to the keys.
|
|
26
|
+
*/
|
|
27
|
+
export function InboxItem({ path }: { readonly path: string }) {
|
|
28
|
+
const counted = useQuery(inboxCount).data;
|
|
29
|
+
const here = inInbox(path);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<SidebarMenu aria-label="Inbox">
|
|
33
|
+
<SidebarMenuItem>
|
|
34
|
+
<SidebarMenuButton
|
|
35
|
+
tooltip={{
|
|
36
|
+
children: (
|
|
37
|
+
<>
|
|
38
|
+
Inbox
|
|
39
|
+
<Keys keys={hotkeys.inbox} />
|
|
40
|
+
</>
|
|
41
|
+
),
|
|
42
|
+
}}
|
|
43
|
+
isActive={here}
|
|
44
|
+
className="group-has-data-[sidebar=menu-badge]/menu-item:pr-14"
|
|
45
|
+
render={
|
|
46
|
+
<Go
|
|
47
|
+
href={inboxPath}
|
|
48
|
+
aria-current={here ? 'page' : undefined}
|
|
49
|
+
data-hotkey={hotkeys.inbox}
|
|
50
|
+
/>
|
|
51
|
+
}
|
|
52
|
+
>
|
|
53
|
+
<InboxIcon aria-hidden />
|
|
54
|
+
<span className="truncate">Inbox</span>
|
|
55
|
+
</SidebarMenuButton>
|
|
56
|
+
<SidebarMenuBadge>
|
|
57
|
+
<HotkeyHint keys={hotkeys.inbox}>
|
|
58
|
+
{counted !== undefined && counted.count > 0 && (
|
|
59
|
+
<Count value={counted.count} more={counted.more} />
|
|
60
|
+
)}
|
|
61
|
+
</HotkeyHint>
|
|
62
|
+
</SidebarMenuBadge>
|
|
63
|
+
</SidebarMenuItem>
|
|
64
|
+
</SidebarMenu>
|
|
65
|
+
);
|
|
66
|
+
}
|