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,65 @@
|
|
|
1
|
+
import { keepPreviousData, queryOptions, useQueries } from '@tanstack/react-query';
|
|
2
|
+
|
|
3
|
+
import { github } from '../clients/clients.ts';
|
|
4
|
+
import type { RepoPlace } from '../code/places.ts';
|
|
5
|
+
import type { ThreadPage } from './threads.ts';
|
|
6
|
+
|
|
7
|
+
/** A release's tag, read by its ID, or `undefined` for one gone, a 404, or a read that failed. */
|
|
8
|
+
const tagOf = async (place: RepoPlace, release: number) => {
|
|
9
|
+
try {
|
|
10
|
+
const answer = await github.GET('/repos/{owner}/{repo}/releases/{release_id}', {
|
|
11
|
+
params: { path: { ...place, release_id: release } },
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
return answer.data?.tag_name;
|
|
15
|
+
} catch {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The tags of `page`'s release threads, by thread ID: every read at once, so the page waits for
|
|
22
|
+
* none in turn, kept under the threads and the times each moved, as its subjects' states are. A
|
|
23
|
+
* read that fails leaves its thread out, once, with no error on the inbox.
|
|
24
|
+
*/
|
|
25
|
+
const releaseTags = (page: ThreadPage) => {
|
|
26
|
+
const asked = page.threads.flatMap((thread) =>
|
|
27
|
+
thread.subject.kind === 'release' && thread.subject.release !== undefined
|
|
28
|
+
? [{ thread, release: thread.subject.release }]
|
|
29
|
+
: [],
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return queryOptions({
|
|
33
|
+
queryKey: [
|
|
34
|
+
'inbox',
|
|
35
|
+
'release-tags',
|
|
36
|
+
...asked.map(({ thread }) => `${thread.id}@${thread.updatedAt}`),
|
|
37
|
+
],
|
|
38
|
+
queryFn: async (): Promise<ReadonlyMap<string, string>> => {
|
|
39
|
+
const tags = await Promise.all(
|
|
40
|
+
asked.map(({ thread, release }) => tagOf(thread.place, release)),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return new Map(
|
|
44
|
+
asked.flatMap(({ thread }, n) => {
|
|
45
|
+
const tag = tags[n];
|
|
46
|
+
|
|
47
|
+
return tag === undefined ? [] : [[thread.id, tag] as const];
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
enabled: asked.length > 0,
|
|
52
|
+
staleTime: 30_000,
|
|
53
|
+
placeholderData: keepPreviousData,
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The tags of every page's release threads, by thread ID: one query a page, which reads each of its
|
|
59
|
+
* release threads' tags at once, kept as `useSubjectStates` keeps its subjects.
|
|
60
|
+
*/
|
|
61
|
+
export const useReleaseTags = (pages: readonly ThreadPage[]): ReadonlyMap<string, string> => {
|
|
62
|
+
const answers = useQueries({ queries: pages.map(releaseTags) });
|
|
63
|
+
|
|
64
|
+
return new Map(answers.flatMap((answer) => [...(answer.data ?? new Map())]));
|
|
65
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { flow } from 'effect/Function';
|
|
2
|
+
import * as Option from 'effect/Option';
|
|
3
|
+
import * as Schema from 'effect/Schema';
|
|
4
|
+
|
|
5
|
+
import { repoProblem } from '../names/repos.ts';
|
|
6
|
+
import { ownerProblem } from '../names/owners.ts';
|
|
7
|
+
import { inboxPath } from './inbox-item.tsx';
|
|
8
|
+
import { isReason, type InboxFilter, type InboxList } from './threads.ts';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The Inbox page's URL query, each part optional: `all=true` for the All tab, `done=true` for the
|
|
12
|
+
* Done tab, `repo=owner/name` for one repo's threads, and `reason=` for one of GitHub's reasons.
|
|
13
|
+
*/
|
|
14
|
+
export interface InboxSearch {
|
|
15
|
+
readonly all?: boolean | undefined;
|
|
16
|
+
readonly done?: boolean | undefined;
|
|
17
|
+
readonly repo?: string | undefined;
|
|
18
|
+
readonly reason?: string | undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** One part of the query, read alone: a part it can't read is left out, and the rest kept. */
|
|
22
|
+
const part = <A>(schema: Schema.Decoder<A>) =>
|
|
23
|
+
flow(Schema.decodeUnknownOption(schema), Option.getOrUndefined);
|
|
24
|
+
|
|
25
|
+
const readFlag = part(Schema.Boolean);
|
|
26
|
+
|
|
27
|
+
const readText = part(Schema.String);
|
|
28
|
+
|
|
29
|
+
/** The query's parts the Inbox reads, each still unread. */
|
|
30
|
+
const Parts = Schema.Struct({
|
|
31
|
+
all: Schema.optional(Schema.Unknown),
|
|
32
|
+
done: Schema.optional(Schema.Unknown),
|
|
33
|
+
repo: Schema.optional(Schema.Unknown),
|
|
34
|
+
reason: Schema.optional(Schema.Unknown),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/** The parts a query has, or none for one that isn't a query at all. */
|
|
38
|
+
const readParts = flow(
|
|
39
|
+
Schema.decodeUnknownOption(Parts),
|
|
40
|
+
Option.getOrElse((): typeof Parts.Type => ({})),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The Inbox's query, as the router hands it over: its parser reads each value as JSON where it
|
|
45
|
+
* can, so `all=true` comes as `true`, and the rest as text.
|
|
46
|
+
*/
|
|
47
|
+
export const readInboxSearch = flow(readParts, ({ all, done, repo, reason }): InboxSearch => ({
|
|
48
|
+
all: readFlag(all),
|
|
49
|
+
done: readFlag(done),
|
|
50
|
+
repo: readText(repo),
|
|
51
|
+
reason: readText(reason),
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
/** A repo the query names as `owner/name`, or `undefined` for none, or one no repo is named. */
|
|
55
|
+
const repoOf = (text: string | undefined) => {
|
|
56
|
+
const [owner, repo, ...rest] = text?.split('/') ?? [];
|
|
57
|
+
if (owner === undefined || repo === undefined || rest.length > 0) return undefined;
|
|
58
|
+
|
|
59
|
+
return ownerProblem(owner) === undefined && repoProblem(repo) === undefined
|
|
60
|
+
? { owner, repo }
|
|
61
|
+
: undefined;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** The tab a query names: Done before All, and Unread when it names neither. */
|
|
65
|
+
const listOf = (search: InboxSearch): InboxList => {
|
|
66
|
+
if (search.done === true) return 'done';
|
|
67
|
+
|
|
68
|
+
return search.all === true ? 'all' : 'unread';
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** The filter a query asks for: what it can't read is left out, so the page lists all of it. */
|
|
72
|
+
export const filterOf = (search: InboxSearch): InboxFilter => ({
|
|
73
|
+
list: listOf(search),
|
|
74
|
+
repo: repoOf(search.repo),
|
|
75
|
+
reason: search.reason !== undefined && isReason(search.reason) ? search.reason : undefined,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/** The query flag each tab's URL sets: none for Unread, the default. */
|
|
79
|
+
const listParams = { unread: undefined, all: 'all', done: 'done' } as const satisfies Record<
|
|
80
|
+
InboxList,
|
|
81
|
+
string | undefined
|
|
82
|
+
>;
|
|
83
|
+
|
|
84
|
+
/** The Inbox page's URL for `filter`: its query names only what isn't the default. */
|
|
85
|
+
export const inboxHref = (filter: InboxFilter) => {
|
|
86
|
+
const query = new URLSearchParams();
|
|
87
|
+
const tab = listParams[filter.list];
|
|
88
|
+
if (tab !== undefined) query.set(tab, 'true');
|
|
89
|
+
|
|
90
|
+
if (filter.repo !== undefined) query.set('repo', `${filter.repo.owner}/${filter.repo.repo}`);
|
|
91
|
+
|
|
92
|
+
if (filter.reason !== undefined) query.set('reason', filter.reason);
|
|
93
|
+
|
|
94
|
+
const text = query.toString();
|
|
95
|
+
|
|
96
|
+
return text === '' ? inboxPath : `${inboxPath}?${text}`;
|
|
97
|
+
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { keepPreviousData, queryOptions, useQueries } from '@tanstack/react-query';
|
|
2
|
+
import * as Schema from 'effect/Schema';
|
|
3
|
+
|
|
4
|
+
import { query } from '../clients/clients.ts';
|
|
5
|
+
import { subjectNumber, type ThreadPage } from './threads.ts';
|
|
6
|
+
|
|
7
|
+
/** What a row shows of its subject: its state, and who acted on it last. */
|
|
8
|
+
export interface SubjectState {
|
|
9
|
+
readonly state: 'open' | 'closed' | 'merged' | 'draft' | 'not_planned';
|
|
10
|
+
/** Who last commented, or who opened it, with no comment yet. */
|
|
11
|
+
readonly actor: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Login = Schema.NullOr(Schema.Struct({ login: Schema.String }));
|
|
15
|
+
|
|
16
|
+
const Commented = Schema.Struct({
|
|
17
|
+
nodes: Schema.NullOr(Schema.Array(Schema.NullOr(Schema.Struct({ author: Login })))),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const SubjectNode = Schema.NullOr(
|
|
21
|
+
Schema.Union([
|
|
22
|
+
Schema.Struct({
|
|
23
|
+
__typename: Schema.Literal('Issue'),
|
|
24
|
+
state: Schema.Literals(['OPEN', 'CLOSED']),
|
|
25
|
+
stateReason: Schema.NullOr(Schema.String),
|
|
26
|
+
author: Login,
|
|
27
|
+
comments: Commented,
|
|
28
|
+
}),
|
|
29
|
+
Schema.Struct({
|
|
30
|
+
__typename: Schema.Literal('PullRequest'),
|
|
31
|
+
state: Schema.Literals(['OPEN', 'CLOSED', 'MERGED']),
|
|
32
|
+
isDraft: Schema.Boolean,
|
|
33
|
+
author: Login,
|
|
34
|
+
comments: Commented,
|
|
35
|
+
}),
|
|
36
|
+
]),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const SubjectsAnswer = Schema.Record(
|
|
40
|
+
Schema.String,
|
|
41
|
+
Schema.NullOr(Schema.Struct({ issueOrPullRequest: SubjectNode })),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The selection each thread's alias reads: its subject's state, its author, and its last
|
|
46
|
+
* comment's, as a row names who acted last.
|
|
47
|
+
*/
|
|
48
|
+
const subjectFragment = `fragment Subject on IssueOrPullRequest {
|
|
49
|
+
__typename
|
|
50
|
+
... on Issue {
|
|
51
|
+
state
|
|
52
|
+
stateReason
|
|
53
|
+
author {
|
|
54
|
+
login
|
|
55
|
+
}
|
|
56
|
+
comments(last: 1) {
|
|
57
|
+
nodes {
|
|
58
|
+
author {
|
|
59
|
+
login
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
... on PullRequest {
|
|
65
|
+
state
|
|
66
|
+
isDraft
|
|
67
|
+
author {
|
|
68
|
+
login
|
|
69
|
+
}
|
|
70
|
+
comments(last: 1) {
|
|
71
|
+
nodes {
|
|
72
|
+
author {
|
|
73
|
+
login
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}`;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The read of `rows` threads' subjects, `t0` to `t{rows - 1}`, each named by its `owner{n}`,
|
|
82
|
+
* `name{n}` and `number{n}`: one read a page of rows, never one a row. Its two-row form is
|
|
83
|
+
* `packages/github`'s `graphql/fixtures/app/NotificationSubjects.graphql`, so the drop-in's served
|
|
84
|
+
* schema is held to it.
|
|
85
|
+
*/
|
|
86
|
+
export const subjectsOperation = (rows: number) => {
|
|
87
|
+
const each = Array.from({ length: rows }, (_, n) => n);
|
|
88
|
+
const variables = each
|
|
89
|
+
.map((n) => ` $owner${n}: String!\n $name${n}: String!\n $number${n}: Int!`)
|
|
90
|
+
.join('\n');
|
|
91
|
+
const aliases = each
|
|
92
|
+
.map(
|
|
93
|
+
(n) =>
|
|
94
|
+
` t${n}: repository(owner: $owner${n}, name: $name${n}) {\n issueOrPullRequest(number: $number${n}) {\n ...Subject\n }\n }`,
|
|
95
|
+
)
|
|
96
|
+
.join('\n');
|
|
97
|
+
|
|
98
|
+
return `query NotificationSubjects(\n${variables}\n) {\n${aliases}\n}\n\n${subjectFragment}\n`;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
type Node = NonNullable<typeof SubjectNode.Type>;
|
|
102
|
+
|
|
103
|
+
/** A subject's state, as its row's icon shows it. */
|
|
104
|
+
const stateOf = (node: Node): SubjectState['state'] => {
|
|
105
|
+
if (node.__typename === 'PullRequest') {
|
|
106
|
+
if (node.state === 'MERGED') return 'merged';
|
|
107
|
+
|
|
108
|
+
if (node.state === 'CLOSED') return 'closed';
|
|
109
|
+
|
|
110
|
+
return node.isDraft ? 'draft' : 'open';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (node.state === 'OPEN') return 'open';
|
|
114
|
+
|
|
115
|
+
return node.stateReason === 'NOT_PLANNED' ? 'not_planned' : 'closed';
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/** Who acted on a subject last, as its row names them: its last commenter, else its author. */
|
|
119
|
+
const actorOf = (node: Node) =>
|
|
120
|
+
node.comments.nodes?.at(-1)?.author?.login ?? node.author?.login ?? undefined;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The subjects of `page`'s rows, by thread ID: one read, kept under the page's threads and the
|
|
124
|
+
* times each was updated, so a thread that moves reads again, and no other page does. A subject
|
|
125
|
+
* that isn't an issue or a pull request, or that the answer leaves `null`, has no state.
|
|
126
|
+
*/
|
|
127
|
+
const subjectStates = (page: ThreadPage) => {
|
|
128
|
+
const asked = page.threads.flatMap((thread) => {
|
|
129
|
+
const number = subjectNumber(thread.subject);
|
|
130
|
+
|
|
131
|
+
return number === undefined ? [] : [{ thread, number }];
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
return queryOptions({
|
|
135
|
+
queryKey: [
|
|
136
|
+
'inbox',
|
|
137
|
+
'subjects',
|
|
138
|
+
...asked.map(({ thread }) => `${thread.id}@${thread.updatedAt}`),
|
|
139
|
+
],
|
|
140
|
+
queryFn: async (): Promise<ReadonlyMap<string, SubjectState>> => {
|
|
141
|
+
const named = asked.flatMap(
|
|
142
|
+
({ thread, number }, n): (readonly [string, string | number])[] => [
|
|
143
|
+
[`owner${n}`, thread.place.owner],
|
|
144
|
+
[`name${n}`, thread.place.repo],
|
|
145
|
+
[`number${n}`, number],
|
|
146
|
+
],
|
|
147
|
+
);
|
|
148
|
+
const variables = Object.fromEntries(named);
|
|
149
|
+
const answer = await query(
|
|
150
|
+
"The inbox's states",
|
|
151
|
+
subjectsOperation(asked.length),
|
|
152
|
+
variables,
|
|
153
|
+
SubjectsAnswer,
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
return new Map(
|
|
157
|
+
asked.flatMap(({ thread }, n) => {
|
|
158
|
+
const node = answer[`t${n}`]?.issueOrPullRequest;
|
|
159
|
+
|
|
160
|
+
return node === null || node === undefined
|
|
161
|
+
? []
|
|
162
|
+
: [[thread.id, { state: stateOf(node), actor: actorOf(node) }] as const];
|
|
163
|
+
}),
|
|
164
|
+
);
|
|
165
|
+
},
|
|
166
|
+
enabled: asked.length > 0,
|
|
167
|
+
staleTime: 30_000,
|
|
168
|
+
// A page whose thread moved keeps its rows' states while it reads them again.
|
|
169
|
+
placeholderData: keepPreviousData,
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The subjects of every row `pages` has loaded, by thread ID: one read a page, so More reads only
|
|
175
|
+
* its new page's, and a page no thread moved on never reads again. A page whose read hasn't
|
|
176
|
+
* answered, or failed, adds none.
|
|
177
|
+
*/
|
|
178
|
+
export const useSubjectStates = (
|
|
179
|
+
pages: readonly ThreadPage[],
|
|
180
|
+
): ReadonlyMap<string, SubjectState> => {
|
|
181
|
+
const answers = useQueries({ queries: pages.map(subjectStates) });
|
|
182
|
+
|
|
183
|
+
return new Map(answers.flatMap((answer) => [...(answer.data ?? new Map())]));
|
|
184
|
+
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useLocation, useRouteContext } from '@tanstack/react-router';
|
|
3
|
+
import { BellIcon, BellOffIcon, ChevronDownIcon, EyeIcon, EyeOffIcon } from 'lucide-react';
|
|
4
|
+
import { toast } from 'sonner';
|
|
5
|
+
|
|
6
|
+
import type { RepoPlace } from '../code/places.ts';
|
|
7
|
+
import { repoAt } from '../code/repo.ts';
|
|
8
|
+
import { signInHref } from '../components/states/states.tsx';
|
|
9
|
+
import { Badge } from '../components/ui/badge.tsx';
|
|
10
|
+
import { Button, buttonVariants } from '../components/ui/button.tsx';
|
|
11
|
+
import { Separator } from '../components/ui/separator.tsx';
|
|
12
|
+
import {
|
|
13
|
+
DropdownMenu,
|
|
14
|
+
DropdownMenuContent,
|
|
15
|
+
DropdownMenuGroup,
|
|
16
|
+
DropdownMenuLabel,
|
|
17
|
+
DropdownMenuRadioGroup,
|
|
18
|
+
DropdownMenuRadioItem,
|
|
19
|
+
DropdownMenuTrigger,
|
|
20
|
+
} from '../components/ui/dropdown-menu.tsx';
|
|
21
|
+
import {
|
|
22
|
+
notificationsOf,
|
|
23
|
+
repoSubscription,
|
|
24
|
+
subjectSubscription,
|
|
25
|
+
useSubscriptionChange,
|
|
26
|
+
type SubscriptionState,
|
|
27
|
+
} from './subscriptions.ts';
|
|
28
|
+
|
|
29
|
+
/** The Watch menu's choices, in GitHub's order, each with the state it sets on the repo. */
|
|
30
|
+
const watchChoices = [
|
|
31
|
+
{
|
|
32
|
+
state: 'UNSUBSCRIBED',
|
|
33
|
+
label: 'Participating and @mentions',
|
|
34
|
+
detail: 'Only when you take part, are @mentioned or are asked to review.',
|
|
35
|
+
},
|
|
36
|
+
{ state: 'SUBSCRIBED', label: 'All activity', detail: 'Every conversation in this repository.' },
|
|
37
|
+
{ state: 'IGNORED', label: 'Ignore', detail: 'Never, not even when you are @mentioned.' },
|
|
38
|
+
] as const satisfies readonly {
|
|
39
|
+
readonly state: SubscriptionState;
|
|
40
|
+
readonly label: string;
|
|
41
|
+
readonly detail: string;
|
|
42
|
+
}[];
|
|
43
|
+
|
|
44
|
+
const isState = (value: string): value is SubscriptionState =>
|
|
45
|
+
watchChoices.some((choice) => choice.state === value);
|
|
46
|
+
|
|
47
|
+
/** The trigger's words for each state, as GitHub's: what the viewer does now. */
|
|
48
|
+
const watchLabels: Record<SubscriptionState, string> = {
|
|
49
|
+
UNSUBSCRIBED: 'Watch',
|
|
50
|
+
SUBSCRIBED: 'Unwatch',
|
|
51
|
+
IGNORED: 'Stop ignoring',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** The repo's watcher count, beside Watch's words. */
|
|
55
|
+
function Watchers({ count }: { readonly count: number }) {
|
|
56
|
+
return (
|
|
57
|
+
<Badge variant="secondary" aria-label={`${count} watching`}>
|
|
58
|
+
{count}
|
|
59
|
+
</Badge>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The repo header's Watch menu, with its watcher count: how the signed-in viewer hears of the
|
|
65
|
+
* repo, drawn once the drop-in says they may change it. A visitor gets Watch with the count, as
|
|
66
|
+
* REST's repo read gives it, leading to sign-in and back, and the page reads no GraphQL for them.
|
|
67
|
+
* It reads the count itself, so a watch it changes reads the repo again and moves it.
|
|
68
|
+
*/
|
|
69
|
+
export function WatchMenu({ place }: { readonly place: RepoPlace }) {
|
|
70
|
+
const { viewer } = useRouteContext({ from: '__root__' });
|
|
71
|
+
const here = useLocation({ select: (location) => location.href });
|
|
72
|
+
const watchers = useQuery(repoAt(place)).data?.watchers;
|
|
73
|
+
const subscription = useQuery({ ...repoSubscription(place), enabled: viewer !== null }).data;
|
|
74
|
+
const change = useSubscriptionChange(place);
|
|
75
|
+
if (watchers === undefined) return null;
|
|
76
|
+
|
|
77
|
+
if (viewer === null) {
|
|
78
|
+
return (
|
|
79
|
+
<a className={buttonVariants({ variant: 'outline', size: 'sm' })} href={signInHref(here)}>
|
|
80
|
+
<EyeIcon data-icon="inline-start" />
|
|
81
|
+
Watch
|
|
82
|
+
<Watchers count={watchers} />
|
|
83
|
+
</a>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (subscription?.canSubscribe !== true || subscription.state === null) return null;
|
|
88
|
+
|
|
89
|
+
const { id, state } = subscription;
|
|
90
|
+
// The picked item's value, which Base UI hands back untyped.
|
|
91
|
+
const pick = (value: string) => {
|
|
92
|
+
if (!isState(value) || value === state) return;
|
|
93
|
+
|
|
94
|
+
change.mutate({ id, state: value }, { onError: (error) => toast.error(error.message) });
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<DropdownMenu>
|
|
99
|
+
<DropdownMenuTrigger
|
|
100
|
+
render={<Button variant="outline" size="sm" disabled={change.isPending} />}
|
|
101
|
+
>
|
|
102
|
+
{state === 'IGNORED' ? (
|
|
103
|
+
<EyeOffIcon data-icon="inline-start" />
|
|
104
|
+
) : (
|
|
105
|
+
<EyeIcon data-icon="inline-start" />
|
|
106
|
+
)}
|
|
107
|
+
{watchLabels[state]}
|
|
108
|
+
<Watchers count={watchers} />
|
|
109
|
+
<ChevronDownIcon data-icon="inline-end" />
|
|
110
|
+
</DropdownMenuTrigger>
|
|
111
|
+
<DropdownMenuContent align="end" className="w-auto min-w-72">
|
|
112
|
+
<DropdownMenuGroup>
|
|
113
|
+
<DropdownMenuLabel>Notifications</DropdownMenuLabel>
|
|
114
|
+
<DropdownMenuRadioGroup value={state} onValueChange={pick}>
|
|
115
|
+
{watchChoices.map((choice) => (
|
|
116
|
+
<DropdownMenuRadioItem key={choice.state} value={choice.state}>
|
|
117
|
+
<span className="flex flex-col">
|
|
118
|
+
<span>{choice.label}</span>
|
|
119
|
+
<span className="text-meta text-muted-foreground">{choice.detail}</span>
|
|
120
|
+
</span>
|
|
121
|
+
</DropdownMenuRadioItem>
|
|
122
|
+
))}
|
|
123
|
+
</DropdownMenuRadioGroup>
|
|
124
|
+
</DropdownMenuGroup>
|
|
125
|
+
</DropdownMenuContent>
|
|
126
|
+
</DropdownMenu>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A sidebar's last section, Notifications, under its separator: the Subscribe or Unsubscribe
|
|
132
|
+
* button and the line that says why, as `notificationsOf` says, for a signed-in viewer who may
|
|
133
|
+
* read their notifications.
|
|
134
|
+
*/
|
|
135
|
+
export function SubjectNotifications({
|
|
136
|
+
place,
|
|
137
|
+
number,
|
|
138
|
+
}: {
|
|
139
|
+
readonly place: RepoPlace;
|
|
140
|
+
readonly number: number;
|
|
141
|
+
}) {
|
|
142
|
+
const { viewer } = useRouteContext({ from: '__root__' });
|
|
143
|
+
const signedIn = viewer !== null;
|
|
144
|
+
const subject = useQuery({ ...subjectSubscription(place, number), enabled: signedIn }).data;
|
|
145
|
+
const repo = useQuery({ ...repoSubscription(place), enabled: signedIn }).data;
|
|
146
|
+
const change = useSubscriptionChange(place);
|
|
147
|
+
|
|
148
|
+
if (subject === undefined || subject === null || subject.state === null || repo === undefined) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const { id, state } = subject;
|
|
153
|
+
const { line, next } = notificationsOf(
|
|
154
|
+
{ state, canSubscribe: subject.canSubscribe },
|
|
155
|
+
repo?.state ?? null,
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<>
|
|
160
|
+
<Separator />
|
|
161
|
+
<section aria-label="Notifications" className="flex flex-col gap-1.5 text-sm">
|
|
162
|
+
<h2 className="text-meta font-semibold text-muted-foreground">Notifications</h2>
|
|
163
|
+
{next !== null && (
|
|
164
|
+
<Button
|
|
165
|
+
variant="outline"
|
|
166
|
+
size="sm"
|
|
167
|
+
disabled={change.isPending}
|
|
168
|
+
onClick={() =>
|
|
169
|
+
change.mutate({ id, state: next }, { onError: (error) => toast.error(error.message) })
|
|
170
|
+
}
|
|
171
|
+
>
|
|
172
|
+
{next === 'SUBSCRIBED' ? (
|
|
173
|
+
<BellIcon data-icon="inline-start" />
|
|
174
|
+
) : (
|
|
175
|
+
<BellOffIcon data-icon="inline-start" />
|
|
176
|
+
)}
|
|
177
|
+
{next === 'SUBSCRIBED' ? 'Subscribe' : 'Unsubscribe'}
|
|
178
|
+
</Button>
|
|
179
|
+
)}
|
|
180
|
+
<p className="text-meta text-muted-foreground">{line}</p>
|
|
181
|
+
</section>
|
|
182
|
+
</>
|
|
183
|
+
);
|
|
184
|
+
}
|