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,142 @@
|
|
|
1
|
+
import { focusManager, queryOptions, type QueryClient } from '@tanstack/react-query';
|
|
2
|
+
|
|
3
|
+
import { github } from '../clients/clients.ts';
|
|
4
|
+
import { isOid, revisionOf, type At, type Ref, type RepoPlace } from './places.ts';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A code page's URL holds its ref and its path in one splat, `feature/x/src/a.ts`, as GitHub's
|
|
8
|
+
* does. Git refuses `heads/a` beside `heads/a/b`, so at most one of the splat's prefixes is a
|
|
9
|
+
* branch, and it wins: the app asks for each prefix, shortest first, and once one is only a tag,
|
|
10
|
+
* asks whether a longer one is a branch before it takes the tag. A full commit ID needs no asking.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** How long the app trusts what a ref names before asking again: a push may move it. */
|
|
14
|
+
export const refFresh = 30_000;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Whether `refs/<namespace>/<name>` is a ref: one call, remembered for `refFresh`. A name Git
|
|
18
|
+
* refuses, such as one with a part that starts with `.`, names none: the drop-in answers 422.
|
|
19
|
+
*/
|
|
20
|
+
const refExists = (place: RepoPlace, namespace: 'heads' | 'tags', name: string) =>
|
|
21
|
+
queryOptions({
|
|
22
|
+
queryKey: ['ref', place.owner, place.repo, namespace, name],
|
|
23
|
+
queryFn: async () => {
|
|
24
|
+
const answer = await github.GET('/repos/{owner}/{repo}/git/ref/{ref}', {
|
|
25
|
+
params: { path: { ...place, ref: `${namespace}/${name}` } },
|
|
26
|
+
});
|
|
27
|
+
if ([404, 422].includes(answer.response.status)) return false;
|
|
28
|
+
|
|
29
|
+
if (answer.data === undefined) {
|
|
30
|
+
throw new Error(`The ref didn't load (${answer.response.status})`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return true;
|
|
34
|
+
},
|
|
35
|
+
staleTime: refFresh,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/** `splat`'s ref and the path after it, or `undefined` when no prefix of it is a ref. */
|
|
39
|
+
export const atOf = async (
|
|
40
|
+
client: QueryClient,
|
|
41
|
+
place: RepoPlace,
|
|
42
|
+
splat: string,
|
|
43
|
+
): Promise<At | undefined> => {
|
|
44
|
+
const segments = splat.split('/');
|
|
45
|
+
const first = segments[0] ?? '';
|
|
46
|
+
const after = (count: number) => segments.slice(count).join('/');
|
|
47
|
+
if (isOid(first)) return { ...place, ref: { name: first, kind: 'commit' }, path: after(1) };
|
|
48
|
+
|
|
49
|
+
const prefix = (count: number) => segments.slice(0, count).join('/');
|
|
50
|
+
const exists = (namespace: 'heads' | 'tags', count: number) =>
|
|
51
|
+
client.query(refExists(place, namespace, prefix(count)));
|
|
52
|
+
const at = (count: number, kind: 'branch' | 'tag'): At => ({
|
|
53
|
+
...place,
|
|
54
|
+
ref: { name: prefix(count), kind },
|
|
55
|
+
path: after(count),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
for (let count = 1; count <= segments.length; count += 1) {
|
|
59
|
+
const [branch, tag] = await Promise.all([exists('heads', count), exists('tags', count)]);
|
|
60
|
+
if (branch) return at(count, 'branch');
|
|
61
|
+
|
|
62
|
+
if (!tag) continue;
|
|
63
|
+
|
|
64
|
+
const longer = Array.from({ length: segments.length - count }, (_, index) => count + index + 1);
|
|
65
|
+
const branches = await Promise.all(longer.map((each) => exists('heads', each)));
|
|
66
|
+
const found = longer.find((_, index) => branches[index]);
|
|
67
|
+
|
|
68
|
+
return found === undefined ? at(count, 'tag') : at(found, 'branch');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return undefined;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Marks what each ref names stale each time the window has focus again, whatever its age: a push
|
|
76
|
+
* from a terminal moves a branch while the browser is away, so the next click after coming back
|
|
77
|
+
* asks again, at a round trip's cost, rather than drawing the old commit for up to `refFresh`.
|
|
78
|
+
* Answers the call that stops it.
|
|
79
|
+
*/
|
|
80
|
+
export const refsStaleOnFocus = (client: QueryClient) =>
|
|
81
|
+
focusManager.subscribe((focused) => {
|
|
82
|
+
if (!focused) return;
|
|
83
|
+
|
|
84
|
+
for (const kind of ['ref', 'head']) {
|
|
85
|
+
void client.invalidateQueries({ queryKey: [kind], refetchType: 'none' });
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
/** A commit as the drop-in's history lists it, in the fields the code pages read. */
|
|
90
|
+
export interface CommitRow {
|
|
91
|
+
readonly sha: string;
|
|
92
|
+
readonly tree: string;
|
|
93
|
+
readonly message: string;
|
|
94
|
+
readonly author: string;
|
|
95
|
+
readonly login: string | undefined;
|
|
96
|
+
readonly date: string | undefined;
|
|
97
|
+
readonly parents: readonly string[];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** One of `GET /repos/{owner}/{repo}/commits`' items, as a row. */
|
|
101
|
+
export const rowOf = (commit: {
|
|
102
|
+
readonly sha: string;
|
|
103
|
+
readonly commit: {
|
|
104
|
+
readonly message: string;
|
|
105
|
+
readonly tree: { readonly sha: string };
|
|
106
|
+
readonly author: { readonly name?: string; readonly date?: string } | null;
|
|
107
|
+
};
|
|
108
|
+
readonly author: { readonly login: string } | Record<string, never> | null;
|
|
109
|
+
readonly parents: readonly { readonly sha: string }[];
|
|
110
|
+
}): CommitRow => ({
|
|
111
|
+
sha: commit.sha,
|
|
112
|
+
tree: commit.commit.tree.sha,
|
|
113
|
+
message: commit.commit.message,
|
|
114
|
+
author: commit.commit.author?.name ?? 'Unknown',
|
|
115
|
+
login: commit.author !== null && 'login' in commit.author ? commit.author.login : undefined,
|
|
116
|
+
date: commit.commit.author?.date,
|
|
117
|
+
parents: commit.parents.map((parent) => parent.sha),
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The commit `ref` names now: its tree is where a page's paths start, and it's the home page's
|
|
122
|
+
* latest commit. `undefined` for a repository with no commits, or a ref that names none.
|
|
123
|
+
*/
|
|
124
|
+
export const headCommit = (place: RepoPlace, ref: Ref) =>
|
|
125
|
+
queryOptions({
|
|
126
|
+
queryKey: ['head', place.owner, place.repo, ref.kind, ref.name],
|
|
127
|
+
queryFn: async (): Promise<CommitRow | null> => {
|
|
128
|
+
const answer = await github.GET('/repos/{owner}/{repo}/commits', {
|
|
129
|
+
params: { path: place, query: { sha: revisionOf(ref), per_page: 1 } },
|
|
130
|
+
});
|
|
131
|
+
if ([404, 409, 422].includes(answer.response.status)) return null;
|
|
132
|
+
|
|
133
|
+
if (answer.data === undefined) {
|
|
134
|
+
throw new Error(`The latest commit didn't load (${answer.response.status})`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const first = answer.data[0];
|
|
138
|
+
|
|
139
|
+
return first === undefined ? null : rowOf(first);
|
|
140
|
+
},
|
|
141
|
+
staleTime: ref.kind === 'commit' ? Infinity : refFresh,
|
|
142
|
+
});
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { BookOpenIcon, ChevronDownIcon, CodeIcon, HistoryIcon, ScaleIcon } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
import { cn } from '#/lib/cn';
|
|
6
|
+
import { LanguageDot } from '../components/language-dot.tsx';
|
|
7
|
+
import { RelativeTime } from '../components/relative-time.tsx';
|
|
8
|
+
import { Button, buttonVariants } from '../components/ui/button.tsx';
|
|
9
|
+
import { Card, CardContent, CardHeader, CardTitle } from '../components/ui/card.tsx';
|
|
10
|
+
import {
|
|
11
|
+
Empty,
|
|
12
|
+
EmptyContent,
|
|
13
|
+
EmptyDescription,
|
|
14
|
+
EmptyHeader,
|
|
15
|
+
EmptyMedia,
|
|
16
|
+
EmptyTitle,
|
|
17
|
+
} from '../components/ui/empty.tsx';
|
|
18
|
+
import { Markdown } from '../components/markdown/markdown.tsx';
|
|
19
|
+
import { InputGroup, InputGroupAddon, InputGroupInput } from '../components/ui/input-group.tsx';
|
|
20
|
+
import {
|
|
21
|
+
Popover,
|
|
22
|
+
PopoverContent,
|
|
23
|
+
PopoverHeader,
|
|
24
|
+
PopoverTitle,
|
|
25
|
+
PopoverTrigger,
|
|
26
|
+
} from '../components/ui/popover.tsx';
|
|
27
|
+
import { OwnerCard } from '../components/owner-card.tsx';
|
|
28
|
+
import { UserAvatar } from '../components/user-avatar.tsx';
|
|
29
|
+
import { CopyButton, Go } from './controls.tsx';
|
|
30
|
+
import type { FileAt } from './files.ts';
|
|
31
|
+
import { FolderList } from './folder-list.tsx';
|
|
32
|
+
import { GoToFile } from './go-to-file.tsx';
|
|
33
|
+
import type { HomeLoad } from './load.ts';
|
|
34
|
+
import { contextOf, markdownOf } from './markdown-files.ts';
|
|
35
|
+
import { blobHref, commitHref, commitsHref, nameOf, treeHref, type At } from './places.ts';
|
|
36
|
+
import { RefSwitcher } from './ref-switcher.tsx';
|
|
37
|
+
import type { CommitRow } from './refs.ts';
|
|
38
|
+
import type { Repo } from './repo.ts';
|
|
39
|
+
|
|
40
|
+
/** The URL to clone the repository from, with a button to copy it. */
|
|
41
|
+
function CloneUrl({ url }: { readonly url: string }) {
|
|
42
|
+
return (
|
|
43
|
+
<InputGroup>
|
|
44
|
+
<InputGroupInput
|
|
45
|
+
readOnly
|
|
46
|
+
aria-label="Clone URL"
|
|
47
|
+
value={url}
|
|
48
|
+
className="font-mono"
|
|
49
|
+
onFocus={(event) => event.currentTarget.select()}
|
|
50
|
+
/>
|
|
51
|
+
<InputGroupAddon align="inline-end">
|
|
52
|
+
<CopyButton text={url} label="Copy clone URL" look="field" />
|
|
53
|
+
</InputGroupAddon>
|
|
54
|
+
</InputGroup>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function Clone({ url }: { readonly url: string }) {
|
|
59
|
+
return (
|
|
60
|
+
<Popover>
|
|
61
|
+
<PopoverTrigger render={<Button size="lg" />}>
|
|
62
|
+
<CodeIcon data-icon="inline-start" />
|
|
63
|
+
Code
|
|
64
|
+
<ChevronDownIcon data-icon="inline-end" />
|
|
65
|
+
</PopoverTrigger>
|
|
66
|
+
<PopoverContent align="end" className="w-80">
|
|
67
|
+
<PopoverHeader>
|
|
68
|
+
<PopoverTitle>Clone with HTTPS</PopoverTitle>
|
|
69
|
+
</PopoverHeader>
|
|
70
|
+
<CloneUrl url={url} />
|
|
71
|
+
</PopoverContent>
|
|
72
|
+
</Popover>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The commit the default branch names now, over the root's files, and a way to its history. */
|
|
77
|
+
function LatestCommit({ at, head }: { readonly at: At; readonly head: CommitRow }) {
|
|
78
|
+
const who = head.login ?? head.author;
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<CardHeader className="flex flex-wrap items-center gap-x-3 gap-y-1 border-b py-2 [.border-b]:pt-2 [.border-b]:pb-2">
|
|
82
|
+
<span className="flex items-center gap-2 font-medium">
|
|
83
|
+
<UserAvatar login={who} size="sm" account="user" />
|
|
84
|
+
{head.login === undefined ? who : <OwnerCard login={head.login}>{who}</OwnerCard>}
|
|
85
|
+
</span>
|
|
86
|
+
<Go
|
|
87
|
+
href={commitHref(at, head.sha)}
|
|
88
|
+
className="min-w-0 grow basis-40 truncate text-muted-foreground hover:text-foreground hover:underline"
|
|
89
|
+
>
|
|
90
|
+
{head.message.split('\n', 1)[0]}
|
|
91
|
+
</Go>
|
|
92
|
+
<span className="flex items-center gap-2 text-muted-foreground">
|
|
93
|
+
<Go href={commitHref(at, head.sha)} className="font-mono hover:underline">
|
|
94
|
+
{head.sha.slice(0, 7)}
|
|
95
|
+
</Go>
|
|
96
|
+
{head.date !== undefined && <RelativeTime at={head.date} />}
|
|
97
|
+
<Go
|
|
98
|
+
href={commitsHref(at, at.ref.name)}
|
|
99
|
+
className={buttonVariants({ variant: 'ghost', size: 'sm' })}
|
|
100
|
+
>
|
|
101
|
+
<HistoryIcon data-icon="inline-start" />
|
|
102
|
+
History
|
|
103
|
+
</Go>
|
|
104
|
+
</span>
|
|
105
|
+
</CardHeader>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** A repository with no commits yet: how to put the first one there. */
|
|
110
|
+
function NoCommits({ repo }: { readonly repo: Repo }) {
|
|
111
|
+
return (
|
|
112
|
+
<Empty>
|
|
113
|
+
<EmptyHeader>
|
|
114
|
+
<EmptyMedia variant="icon">
|
|
115
|
+
<CodeIcon />
|
|
116
|
+
</EmptyMedia>
|
|
117
|
+
<EmptyTitle>This repository is empty</EmptyTitle>
|
|
118
|
+
<EmptyDescription>Push a branch to it, and its files show here.</EmptyDescription>
|
|
119
|
+
</EmptyHeader>
|
|
120
|
+
<EmptyContent className="w-full max-w-lg">
|
|
121
|
+
<CloneUrl url={repo.cloneUrl} />
|
|
122
|
+
<pre className="w-full overflow-x-auto rounded-md bg-muted p-3 text-left font-mono text-sm">
|
|
123
|
+
{`git remote add origin ${repo.cloneUrl}\ngit push -u origin ${repo.defaultBranch}`}
|
|
124
|
+
</pre>
|
|
125
|
+
</EmptyContent>
|
|
126
|
+
</Empty>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The root's README under its name: rendered when it's Markdown, as written when it's other text,
|
|
132
|
+
* and otherwise a way to its page, which says why it isn't shown.
|
|
133
|
+
*/
|
|
134
|
+
function Readme({ at, file }: { readonly at: At; readonly file: FileAt }) {
|
|
135
|
+
const markdown = markdownOf(file);
|
|
136
|
+
const shown = file.shown;
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<section aria-label="README">
|
|
140
|
+
<Card className="gap-0 py-0">
|
|
141
|
+
<CardHeader className="border-b py-2 [.border-b]:pt-2 [.border-b]:pb-2">
|
|
142
|
+
<CardTitle className="flex items-center gap-2">
|
|
143
|
+
<BookOpenIcon aria-hidden className="size-4 text-muted-foreground" />
|
|
144
|
+
<Go href={blobHref(at, at.ref.name, file.path)} className="hover:underline">
|
|
145
|
+
{nameOf(file.path)}
|
|
146
|
+
</Go>
|
|
147
|
+
</CardTitle>
|
|
148
|
+
</CardHeader>
|
|
149
|
+
<CardContent className="px-6 py-4 text-sm">
|
|
150
|
+
{markdown !== undefined ? (
|
|
151
|
+
<Markdown text={markdown} context={contextOf(at, file.path)} />
|
|
152
|
+
) : shown.kind === 'text' ? (
|
|
153
|
+
<pre className="overflow-x-auto font-mono text-sm whitespace-pre-wrap">
|
|
154
|
+
{shown.text}
|
|
155
|
+
</pre>
|
|
156
|
+
) : (
|
|
157
|
+
<p className="text-muted-foreground">
|
|
158
|
+
This README isn't shown here.{' '}
|
|
159
|
+
<Go href={blobHref(at, at.ref.name, file.path)} className="underline">
|
|
160
|
+
Open it
|
|
161
|
+
</Go>{' '}
|
|
162
|
+
to see why.
|
|
163
|
+
</p>
|
|
164
|
+
)}
|
|
165
|
+
</CardContent>
|
|
166
|
+
</Card>
|
|
167
|
+
</section>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Whether the repository has anything for About to say: a license or a language. */
|
|
172
|
+
const hasAbout = (repo: Repo) => repo.license !== null || repo.language !== null;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* What the repository is, besides its description, which the repo's header shows on every page:
|
|
176
|
+
* its license and language. A repository with neither has no About.
|
|
177
|
+
*/
|
|
178
|
+
function About({ repo }: { readonly repo: Repo }) {
|
|
179
|
+
return (
|
|
180
|
+
<section aria-label="About" className="flex flex-col gap-3">
|
|
181
|
+
<h2 className="text-sm font-medium">About</h2>
|
|
182
|
+
{repo.license !== null && (
|
|
183
|
+
<p className="flex items-center gap-1.5">
|
|
184
|
+
<ScaleIcon aria-hidden className="size-4 text-muted-foreground" />
|
|
185
|
+
{repo.license}
|
|
186
|
+
</p>
|
|
187
|
+
)}
|
|
188
|
+
<LanguageDot name={repo.language} />
|
|
189
|
+
</section>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* A repository's home, at its default branch: the ref and the way to any file, the latest commit,
|
|
195
|
+
* the root's files, and its README, in a column beside what the repository is and `beside` it,
|
|
196
|
+
* such as its latest release. On a phone what it is comes first, as on GitHub, and `beside` last.
|
|
197
|
+
*/
|
|
198
|
+
export function RepoHome({
|
|
199
|
+
load,
|
|
200
|
+
beside,
|
|
201
|
+
}: {
|
|
202
|
+
readonly load: HomeLoad;
|
|
203
|
+
readonly beside?: ReactNode;
|
|
204
|
+
}) {
|
|
205
|
+
const { repo, at, head, root, readme } = load;
|
|
206
|
+
if (head === null || root === null) return <NoCommits repo={repo} />;
|
|
207
|
+
|
|
208
|
+
// Two rows on the right, the code spanning both, so the column's sections stack under About
|
|
209
|
+
// without stretching the first row to the code's height.
|
|
210
|
+
return (
|
|
211
|
+
<div className="grid gap-6 text-sm lg:grid-cols-[minmax(0,1fr)_16rem] lg:grid-rows-[auto_1fr]">
|
|
212
|
+
{hasAbout(repo) && (
|
|
213
|
+
<div className="lg:col-start-2 lg:row-start-1">
|
|
214
|
+
<About repo={repo} />
|
|
215
|
+
</div>
|
|
216
|
+
)}
|
|
217
|
+
<div className="flex min-w-0 flex-col gap-3 lg:col-start-1 lg:row-span-2 lg:row-start-1">
|
|
218
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
219
|
+
<RefSwitcher place={at} here={at.ref} hrefOf={(ref) => treeHref(at, ref, '')} />
|
|
220
|
+
<span className="ml-auto flex items-center gap-2">
|
|
221
|
+
<GoToFile at={at} root={head.tree} />
|
|
222
|
+
<Clone url={repo.cloneUrl} />
|
|
223
|
+
</span>
|
|
224
|
+
</div>
|
|
225
|
+
<FolderList at={at} folder={root} header={<LatestCommit at={at} head={head} />} />
|
|
226
|
+
{readme !== null && <Readme at={at} file={readme} />}
|
|
227
|
+
</div>
|
|
228
|
+
{beside !== undefined && (
|
|
229
|
+
<div
|
|
230
|
+
className={cn(
|
|
231
|
+
'border-t pt-6 lg:col-start-2',
|
|
232
|
+
hasAbout(repo) ? 'lg:row-start-2' : 'lg:row-start-1 lg:border-t-0 lg:pt-0',
|
|
233
|
+
)}
|
|
234
|
+
>
|
|
235
|
+
{beside}
|
|
236
|
+
</div>
|
|
237
|
+
)}
|
|
238
|
+
</div>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { queryOptions } from '@tanstack/react-query';
|
|
2
|
+
|
|
3
|
+
import { github } from '../clients/clients.ts';
|
|
4
|
+
import type { RepoPlace } from './places.ts';
|
|
5
|
+
|
|
6
|
+
/** A way GitHub merges a pull request, as `merge_method` names it. */
|
|
7
|
+
export type MergeMethod = 'merge' | 'squash' | 'rebase';
|
|
8
|
+
|
|
9
|
+
/** A repository, in the fields its pages read. */
|
|
10
|
+
export interface Repo {
|
|
11
|
+
readonly owner: string;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly private: boolean;
|
|
14
|
+
readonly description: string | null;
|
|
15
|
+
readonly defaultBranch: string;
|
|
16
|
+
readonly cloneUrl: string;
|
|
17
|
+
/** Whether the repo's issues are switched on, as its settings' Issues switch says. */
|
|
18
|
+
readonly hasIssues: boolean;
|
|
19
|
+
/** How its pull requests may merge, as its settings' merge buttons allow, in GitHub's order. */
|
|
20
|
+
readonly mergeMethods: readonly MergeMethod[];
|
|
21
|
+
/** The language with the most bytes, or `null` before the drop-in has counted them. */
|
|
22
|
+
readonly language: string | null;
|
|
23
|
+
/** Its license as GitHub's About names it, such as "MIT license", or `null` for none. */
|
|
24
|
+
readonly license: string | null;
|
|
25
|
+
/** Who watches it at All activity, as the Watch menu counts them: GitHub's `subscribers_count`. */
|
|
26
|
+
readonly watchers: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A license's words in the About column: its SPDX ID, as GitHub shows it, or its name where it
|
|
31
|
+
* has none, as for "Other".
|
|
32
|
+
*/
|
|
33
|
+
const licenseOf = (
|
|
34
|
+
license: { readonly name: string; readonly spdx_id: string | null } | null | undefined,
|
|
35
|
+
) => {
|
|
36
|
+
if (license === null || license === undefined) return null;
|
|
37
|
+
|
|
38
|
+
const id =
|
|
39
|
+
license.spdx_id === null || license.spdx_id === 'NOASSERTION' ? license.name : license.spdx_id;
|
|
40
|
+
|
|
41
|
+
return `${id} license`;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** The repository `place` names, or `null` when the viewer can't read one there. */
|
|
45
|
+
export const repoAt = (place: RepoPlace) =>
|
|
46
|
+
queryOptions({
|
|
47
|
+
queryKey: ['repo', place.owner, place.repo],
|
|
48
|
+
queryFn: async (): Promise<Repo | null> => {
|
|
49
|
+
const answer = await github.GET('/repos/{owner}/{repo}', { params: { path: place } });
|
|
50
|
+
// A visitor gets 401 at a private or missing repo (Q139); a signed-in reader gets 404.
|
|
51
|
+
// Neither says which it is. A session whose token Git refuses ends in `callApi`, which asks
|
|
52
|
+
// again as a visitor, so a 401 is always a visitor's.
|
|
53
|
+
if (answer.response.status === 404 || answer.response.status === 401) return null;
|
|
54
|
+
|
|
55
|
+
if (answer.data === undefined) {
|
|
56
|
+
throw new Error(`The repository didn't load (${answer.response.status})`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const repo = answer.data;
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
owner: repo.owner.login,
|
|
63
|
+
name: repo.name,
|
|
64
|
+
private: repo.private,
|
|
65
|
+
description: repo.description,
|
|
66
|
+
defaultBranch: repo.default_branch,
|
|
67
|
+
cloneUrl: repo.clone_url,
|
|
68
|
+
hasIssues: repo.has_issues,
|
|
69
|
+
// GitHub leaves out a setting it doesn't show the reader, which leaves its default on.
|
|
70
|
+
mergeMethods: (
|
|
71
|
+
[
|
|
72
|
+
['merge', repo.allow_merge_commit],
|
|
73
|
+
['squash', repo.allow_squash_merge],
|
|
74
|
+
['rebase', repo.allow_rebase_merge],
|
|
75
|
+
] as const
|
|
76
|
+
).flatMap(([method, allowed]) => (allowed === false ? [] : [method])),
|
|
77
|
+
language: repo.language ?? null,
|
|
78
|
+
license: licenseOf(repo.license),
|
|
79
|
+
watchers: repo.subscribers_count,
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
staleTime: 30_000,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
/** A list of `ref`'s names, branches' or tags', a page of 100 at a time from `after`. */
|
|
86
|
+
export const refNames = async (
|
|
87
|
+
place: RepoPlace,
|
|
88
|
+
kind: 'branches' | 'tags',
|
|
89
|
+
after: string | undefined,
|
|
90
|
+
) => {
|
|
91
|
+
// `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it, and
|
|
92
|
+
// the client leaves out what's `undefined`.
|
|
93
|
+
const paging = { per_page: 100, after };
|
|
94
|
+
const query = { ...paging };
|
|
95
|
+
const answer =
|
|
96
|
+
kind === 'branches'
|
|
97
|
+
? await github.GET('/repos/{owner}/{repo}/branches', { params: { path: place, query } })
|
|
98
|
+
: await github.GET('/repos/{owner}/{repo}/tags', { params: { path: place, query } });
|
|
99
|
+
|
|
100
|
+
if (answer.data === undefined) {
|
|
101
|
+
throw new Error(`The ${kind} didn't load (${answer.response.status})`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return { names: answer.data.map((ref) => ref.name), link: answer.response.headers.get('link') };
|
|
105
|
+
};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import * as Option from 'effect/Option';
|
|
2
|
+
import * as Schema from 'effect/Schema';
|
|
3
|
+
|
|
4
|
+
import type { FileAt } from './files.ts';
|
|
5
|
+
import type { Folder } from './trees.ts';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Saved reads: a public repo's trees and files at a commit, kept in the browser for the account
|
|
9
|
+
* that read them, so a new page draws them without asking again (F11). What may be saved, and
|
|
10
|
+
* when one may be drawn, is `saved.ts`'s; this is only where they're kept.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** A read the app may save: a folder or a file, at a commit. */
|
|
14
|
+
export type Savable = Folder | FileAt;
|
|
15
|
+
|
|
16
|
+
/** Where an account's saved reads are kept, each under its repo and its query's hash. */
|
|
17
|
+
export interface SavedReads {
|
|
18
|
+
/** The read saved as `hash` in `repo`, or `undefined` for none or one past `savedFor`. */
|
|
19
|
+
readonly get: (repo: string, hash: string) => Promise<Savable | undefined>;
|
|
20
|
+
readonly put: (repo: string, hash: string, value: Savable) => Promise<void>;
|
|
21
|
+
/** Drops `repo`'s saved reads, as when it answers private or gone. */
|
|
22
|
+
readonly drop: (repo: string) => Promise<void>;
|
|
23
|
+
/** Drops every saved read of the account, as on sign-out or when its session ends. */
|
|
24
|
+
readonly clear: () => Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** How long a saved read is drawn: a week after it was read. */
|
|
28
|
+
export const savedFor = 7 * 24 * 60 * 60 * 1000;
|
|
29
|
+
|
|
30
|
+
/** How many reads an account keeps: past it, the oldest go. */
|
|
31
|
+
export const savedMost = 1000;
|
|
32
|
+
|
|
33
|
+
/** One saved read, as kept. */
|
|
34
|
+
interface Saved {
|
|
35
|
+
readonly repo: string;
|
|
36
|
+
readonly hash: string;
|
|
37
|
+
readonly value: Savable;
|
|
38
|
+
readonly savedAt: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A visitor's saved reads' IndexedDB database, and the start of each account's. */
|
|
42
|
+
const visitorsDatabase = 'ref0-reads';
|
|
43
|
+
|
|
44
|
+
/** The IndexedDB database an account's reads are kept in: a visitor's has no account in its name. */
|
|
45
|
+
const databaseOf = (account: string | null) =>
|
|
46
|
+
account === null ? visitorsDatabase : `${visitorsDatabase}:${account}`;
|
|
47
|
+
|
|
48
|
+
const store = 'reads';
|
|
49
|
+
|
|
50
|
+
/** Past every hash, as the top of a repo's range of keys. */
|
|
51
|
+
const highest = String.fromCharCode(0xffff);
|
|
52
|
+
|
|
53
|
+
/** An image's bytes, as structured clone keeps a `Uint8Array` over its own `ArrayBuffer`. */
|
|
54
|
+
const ImageBytes = Schema.declare(
|
|
55
|
+
(input): input is Uint8Array<ArrayBuffer> =>
|
|
56
|
+
input instanceof Uint8Array && input.buffer instanceof ArrayBuffer,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const SavedEntry = Schema.Struct({
|
|
60
|
+
name: Schema.String,
|
|
61
|
+
path: Schema.String,
|
|
62
|
+
kind: Schema.Literals(['file', 'folder', 'submodule', 'symlink']),
|
|
63
|
+
sha: Schema.String,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const SavedFolder = Schema.Struct({
|
|
67
|
+
path: Schema.String,
|
|
68
|
+
sha: Schema.String,
|
|
69
|
+
entries: Schema.Array(SavedEntry),
|
|
70
|
+
truncated: Schema.Boolean,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const SavedFile = Schema.Struct({
|
|
74
|
+
path: Schema.String,
|
|
75
|
+
commit: Schema.String,
|
|
76
|
+
sha: Schema.String,
|
|
77
|
+
size: Schema.UndefinedOr(Schema.Number),
|
|
78
|
+
lfs: Schema.optionalKey(
|
|
79
|
+
Schema.Struct({ size: Schema.Number, stored: Schema.UndefinedOr(Schema.Boolean) }),
|
|
80
|
+
),
|
|
81
|
+
shown: Schema.Union([
|
|
82
|
+
Schema.Struct({ kind: Schema.Literal('text'), text: Schema.String }),
|
|
83
|
+
Schema.Struct({
|
|
84
|
+
kind: Schema.Literal('image'),
|
|
85
|
+
type: Schema.String,
|
|
86
|
+
bytes: Schema.UndefinedOr(ImageBytes),
|
|
87
|
+
}),
|
|
88
|
+
Schema.Struct({ kind: Schema.Literals(['binary', 'tooBig', 'tooBigToRead']) }),
|
|
89
|
+
Schema.Struct({ kind: Schema.Literal('symlink'), target: Schema.String }),
|
|
90
|
+
]),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/** A saved read as IndexedDB gives it back, read: a folder or a file, or nothing it can draw. */
|
|
94
|
+
const savableOf = Schema.decodeUnknownOption(Schema.Union([SavedFolder, SavedFile]));
|
|
95
|
+
|
|
96
|
+
/** A row as IndexedDB answers it, read: when it was saved, and its value, for `savableOf` to read. */
|
|
97
|
+
const rowOf = Schema.decodeUnknownOption(
|
|
98
|
+
Schema.Struct({ savedAt: Schema.Number, value: Schema.Unknown }),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
/** `request`'s answer, once the browser gives it. */
|
|
102
|
+
const answered = <Answer>(request: IDBRequest<Answer>) =>
|
|
103
|
+
new Promise<Answer>((done, failed) => {
|
|
104
|
+
request.addEventListener('success', () => done(request.result));
|
|
105
|
+
request.addEventListener('error', () => failed(request.error));
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const opened = (name: string) =>
|
|
109
|
+
new Promise<IDBDatabase>((done, failed) => {
|
|
110
|
+
const request = indexedDB.open(name, 1);
|
|
111
|
+
request.addEventListener('upgradeneeded', () => {
|
|
112
|
+
request.result.createObjectStore(store).createIndex('savedAt', 'savedAt');
|
|
113
|
+
});
|
|
114
|
+
request.addEventListener('success', () => {
|
|
115
|
+
// Another tab's sign-out deletes the database: this one lets go of it so the delete can.
|
|
116
|
+
request.result.addEventListener('versionchange', () => request.result.close());
|
|
117
|
+
done(request.result);
|
|
118
|
+
});
|
|
119
|
+
request.addEventListener('error', () => failed(request.error));
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* An account's saved reads in IndexedDB, one database an account, so a sign-out deletes the whole
|
|
124
|
+
* of it, each value read back through `savableOf`, as what's on disk may be another version's
|
|
125
|
+
* or changed by hand. A browser that refuses IndexedDB, as some private windows do, saves and draws
|
|
126
|
+
* nothing.
|
|
127
|
+
*/
|
|
128
|
+
export const indexedReads = (account: string | null): SavedReads => {
|
|
129
|
+
const name = databaseOf(account);
|
|
130
|
+
let database: Promise<IDBDatabase> | undefined;
|
|
131
|
+
const reads = (mode: IDBTransactionMode) => {
|
|
132
|
+
database ??= opened(name);
|
|
133
|
+
|
|
134
|
+
return database.then((open) => open.transaction(store, mode).objectStore(store));
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const quietly = async <Answer>(work: () => Promise<Answer>) => {
|
|
138
|
+
try {
|
|
139
|
+
return await work();
|
|
140
|
+
} catch {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
get: (repo, hash) =>
|
|
147
|
+
quietly(async () => {
|
|
148
|
+
const row = rowOf(await answered((await reads('readonly')).get([repo, hash])));
|
|
149
|
+
if (Option.isNone(row) || Date.now() - row.value.savedAt > savedFor) return undefined;
|
|
150
|
+
|
|
151
|
+
return Option.getOrUndefined(savableOf(row.value.value));
|
|
152
|
+
}),
|
|
153
|
+
put: async (repo, hash, value) => {
|
|
154
|
+
await quietly(async () => {
|
|
155
|
+
const saving = await reads('readwrite');
|
|
156
|
+
const saved: Saved = { repo, hash, value, savedAt: Date.now() };
|
|
157
|
+
await answered(saving.put(saved, [repo, hash]));
|
|
158
|
+
|
|
159
|
+
const over = (await answered(saving.count())) - savedMost;
|
|
160
|
+
if (over <= 0) return;
|
|
161
|
+
|
|
162
|
+
const oldest = await answered(saving.index('savedAt').getAllKeys(null, over));
|
|
163
|
+
|
|
164
|
+
for (const key of oldest) saving.delete(key);
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
drop: async (repo) => {
|
|
168
|
+
await quietly(async () => {
|
|
169
|
+
await answered(
|
|
170
|
+
(await reads('readwrite')).delete(IDBKeyRange.bound([repo, ''], [repo, highest])),
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
clear: async () => {
|
|
175
|
+
await quietly(async () => {
|
|
176
|
+
(await database)?.close();
|
|
177
|
+
database = undefined;
|
|
178
|
+
await answered(indexedDB.deleteDatabase(name));
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Drops every account's saved reads, and a visitor's, as when a page load learns its sign-in ended
|
|
186
|
+
* and can't tell whose they were.
|
|
187
|
+
*/
|
|
188
|
+
export const dropEveryAccount = async () => {
|
|
189
|
+
try {
|
|
190
|
+
const databases = await indexedDB.databases();
|
|
191
|
+
const ours = databases.flatMap(({ name }) =>
|
|
192
|
+
name === visitorsDatabase || name?.startsWith(`${visitorsDatabase}:`) === true ? [name] : [],
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
await Promise.all(ours.map((name) => answered(indexedDB.deleteDatabase(name))));
|
|
196
|
+
} catch {
|
|
197
|
+
// A browser that refuses IndexedDB saved nothing.
|
|
198
|
+
}
|
|
199
|
+
};
|