ref0-git 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/apps/github/.dev.vars.example +6 -0
- package/app/apps/github/README.md +70 -0
- package/app/apps/github/THIRD_PARTY_NOTICES.md +214 -0
- package/app/apps/github/components.json +25 -0
- package/app/apps/github/generated/git-rest.ts +10444 -0
- package/app/apps/github/generated/routeTree.gen.ts +1242 -0
- package/app/apps/github/migrations/postgres/0001_auth.sql +46 -0
- package/app/apps/github/migrations/sql/0001_auth.sql +19 -0
- package/app/apps/github/migrations/sql/0002_passkeys.sql +9 -0
- package/app/apps/github/migrations/sql/0003_orgs.sql +22 -0
- package/app/apps/github/migrations/sql/0004_avatars.sql +6 -0
- package/app/apps/github/package.json +80 -0
- package/app/apps/github/src/branches/branch-list.tsx +385 -0
- package/app/apps/github/src/branches/branches.ts +55 -0
- package/app/apps/github/src/clients/allowed.ts +213 -0
- package/app/apps/github/src/clients/at-most.ts +17 -0
- package/app/apps/github/src/clients/avatars.ts +410 -0
- package/app/apps/github/src/clients/cached.ts +65 -0
- package/app/apps/github/src/clients/calls.ts +160 -0
- package/app/apps/github/src/clients/clients.ts +82 -0
- package/app/apps/github/src/clients/graphql.ts +50 -0
- package/app/apps/github/src/clients/host-answer.ts +28 -0
- package/app/apps/github/src/clients/host-calls.ts +382 -0
- package/app/apps/github/src/clients/icon-bytes.ts +203 -0
- package/app/apps/github/src/clients/proxy.ts +59 -0
- package/app/apps/github/src/clients/session-ended.ts +18 -0
- package/app/apps/github/src/clients/transfers.ts +212 -0
- package/app/apps/github/src/code/breadcrumbs.tsx +50 -0
- package/app/apps/github/src/code/code-page.tsx +147 -0
- package/app/apps/github/src/code/code-tree.tsx +338 -0
- package/app/apps/github/src/code/controls.tsx +230 -0
- package/app/apps/github/src/code/file-view.tsx +450 -0
- package/app/apps/github/src/code/files.ts +332 -0
- package/app/apps/github/src/code/folder-list.tsx +122 -0
- package/app/apps/github/src/code/go-to-file.tsx +131 -0
- package/app/apps/github/src/code/highlighted.tsx +58 -0
- package/app/apps/github/src/code/lines.ts +46 -0
- package/app/apps/github/src/code/load.ts +147 -0
- package/app/apps/github/src/code/markdown-files.ts +58 -0
- package/app/apps/github/src/code/places.ts +88 -0
- package/app/apps/github/src/code/ref-pages.ts +179 -0
- package/app/apps/github/src/code/ref-switcher.tsx +203 -0
- package/app/apps/github/src/code/refs.ts +142 -0
- package/app/apps/github/src/code/repo-home.tsx +240 -0
- package/app/apps/github/src/code/repo.ts +105 -0
- package/app/apps/github/src/code/saved-reads.ts +199 -0
- package/app/apps/github/src/code/saved.ts +110 -0
- package/app/apps/github/src/code/tree-fold.ts +186 -0
- package/app/apps/github/src/code/trees.ts +136 -0
- package/app/apps/github/src/components/avatar-picture.ts +53 -0
- package/app/apps/github/src/components/avatar-url.ts +16 -0
- package/app/apps/github/src/components/confirm-action.tsx +100 -0
- package/app/apps/github/src/components/count.tsx +24 -0
- package/app/apps/github/src/components/create-button.tsx +38 -0
- package/app/apps/github/src/components/file-icons/file-icons.css +225 -0
- package/app/apps/github/src/components/file-icons/file-icons.tsx +138 -0
- package/app/apps/github/src/components/filter.tsx +35 -0
- package/app/apps/github/src/components/hotkeys/hotkeys.tsx +255 -0
- package/app/apps/github/src/components/item-list.tsx +65 -0
- package/app/apps/github/src/components/language-dot.tsx +29 -0
- package/app/apps/github/src/components/list-toolbar.tsx +82 -0
- package/app/apps/github/src/components/markdown/editor.tsx +57 -0
- package/app/apps/github/src/components/markdown/markdown.css +177 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +82 -0
- package/app/apps/github/src/components/owner-card.tsx +196 -0
- package/app/apps/github/src/components/pull-status.tsx +34 -0
- package/app/apps/github/src/components/recent.ts +41 -0
- package/app/apps/github/src/components/relative-time.tsx +78 -0
- package/app/apps/github/src/components/repos/icon-hashes.ts +91 -0
- package/app/apps/github/src/components/repos/new-repo-form.tsx +196 -0
- package/app/apps/github/src/components/repos/repo-icon.tsx +47 -0
- package/app/apps/github/src/components/repos/repo-list.tsx +528 -0
- package/app/apps/github/src/components/repos/your-repos.tsx +124 -0
- package/app/apps/github/src/components/review-state.tsx +75 -0
- package/app/apps/github/src/components/route-dialog.tsx +137 -0
- package/app/apps/github/src/components/save-button.tsx +58 -0
- package/app/apps/github/src/components/shell/app-shell.tsx +164 -0
- package/app/apps/github/src/components/shell/create-org-dialog.tsx +118 -0
- package/app/apps/github/src/components/shell/create-row.tsx +49 -0
- package/app/apps/github/src/components/shell/link-menu.tsx +94 -0
- package/app/apps/github/src/components/shell/nav-user.tsx +97 -0
- package/app/apps/github/src/components/shell/owner-repos.tsx +247 -0
- package/app/apps/github/src/components/shell/owner-switcher.tsx +104 -0
- package/app/apps/github/src/components/shell/repo-switcher.tsx +179 -0
- package/app/apps/github/src/components/shell/sections.ts +31 -0
- package/app/apps/github/src/components/shell/submenu-chevron.ts +147 -0
- package/app/apps/github/src/components/signin/device-card.tsx +139 -0
- package/app/apps/github/src/components/signin/login-form.tsx +88 -0
- package/app/apps/github/src/components/signin/signin-page.tsx +33 -0
- package/app/apps/github/src/components/signin/signup-form.tsx +106 -0
- package/app/apps/github/src/components/states/live-status.tsx +42 -0
- package/app/apps/github/src/components/states/states.tsx +126 -0
- package/app/apps/github/src/components/tab-indicator.tsx +143 -0
- package/app/apps/github/src/components/theme-choice.tsx +108 -0
- package/app/apps/github/src/components/theme-provider.tsx +126 -0
- package/app/apps/github/src/components/tones.ts +23 -0
- package/app/apps/github/src/components/ui/alert-dialog.tsx +187 -0
- package/app/apps/github/src/components/ui/alert.tsx +78 -0
- package/app/apps/github/src/components/ui/avatar.tsx +106 -0
- package/app/apps/github/src/components/ui/badge.tsx +51 -0
- package/app/apps/github/src/components/ui/breadcrumb.tsx +124 -0
- package/app/apps/github/src/components/ui/button-group.tsx +87 -0
- package/app/apps/github/src/components/ui/button.tsx +61 -0
- package/app/apps/github/src/components/ui/calendar.tsx +221 -0
- package/app/apps/github/src/components/ui/card.tsx +102 -0
- package/app/apps/github/src/components/ui/checkbox.tsx +26 -0
- package/app/apps/github/src/components/ui/collapsible.tsx +19 -0
- package/app/apps/github/src/components/ui/combobox.tsx +304 -0
- package/app/apps/github/src/components/ui/command.tsx +208 -0
- package/app/apps/github/src/components/ui/dialog.tsx +156 -0
- package/app/apps/github/src/components/ui/dropdown-menu.tsx +290 -0
- package/app/apps/github/src/components/ui/empty.tsx +100 -0
- package/app/apps/github/src/components/ui/field.tsx +236 -0
- package/app/apps/github/src/components/ui/hover-card.tsx +48 -0
- package/app/apps/github/src/components/ui/input-group.tsx +163 -0
- package/app/apps/github/src/components/ui/input.tsx +19 -0
- package/app/apps/github/src/components/ui/item.tsx +201 -0
- package/app/apps/github/src/components/ui/kbd.tsx +27 -0
- package/app/apps/github/src/components/ui/label.tsx +33 -0
- package/app/apps/github/src/components/ui/popover.tsx +87 -0
- package/app/apps/github/src/components/ui/radio-group.tsx +35 -0
- package/app/apps/github/src/components/ui/select.tsx +198 -0
- package/app/apps/github/src/components/ui/separator.tsx +22 -0
- package/app/apps/github/src/components/ui/sheet.tsx +138 -0
- package/app/apps/github/src/components/ui/sidebar.tsx +724 -0
- package/app/apps/github/src/components/ui/skeleton.tsx +13 -0
- package/app/apps/github/src/components/ui/sonner.tsx +47 -0
- package/app/apps/github/src/components/ui/styles.css +242 -0
- package/app/apps/github/src/components/ui/table.tsx +113 -0
- package/app/apps/github/src/components/ui/tabs.tsx +79 -0
- package/app/apps/github/src/components/ui/textarea.tsx +17 -0
- package/app/apps/github/src/components/ui/title.ts +6 -0
- package/app/apps/github/src/components/ui/toggle-group.tsx +89 -0
- package/app/apps/github/src/components/ui/toggle.tsx +42 -0
- package/app/apps/github/src/components/ui/tooltip.tsx +63 -0
- package/app/apps/github/src/components/user-avatar.tsx +145 -0
- package/app/apps/github/src/components/view-tabs.tsx +42 -0
- package/app/apps/github/src/context/context.ts +133 -0
- package/app/apps/github/src/diffs/blobs.ts +94 -0
- package/app/apps/github/src/diffs/diff-view.tsx +155 -0
- package/app/apps/github/src/diffs/files.ts +121 -0
- package/app/apps/github/src/diffs/hunks.tsx +454 -0
- package/app/apps/github/src/diffs/patch.ts +131 -0
- package/app/apps/github/src/diffs/rows.ts +137 -0
- package/app/apps/github/src/history/commit-diff.ts +54 -0
- package/app/apps/github/src/history/commit-list.tsx +207 -0
- package/app/apps/github/src/history/commit-page.tsx +147 -0
- package/app/apps/github/src/history/history.ts +129 -0
- package/app/apps/github/src/hooks/allowed.ts +31 -0
- package/app/apps/github/src/hooks/answers.ts +65 -0
- package/app/apps/github/src/hooks/avatars.ts +54 -0
- package/app/apps/github/src/hooks/draft.ts +38 -0
- package/app/apps/github/src/hooks/open-counts.ts +127 -0
- package/app/apps/github/src/hooks/profiles.ts +120 -0
- package/app/apps/github/src/hooks/repos.ts +440 -0
- package/app/apps/github/src/hooks/use-mobile.ts +19 -0
- package/app/apps/github/src/hooks/viewer.ts +39 -0
- package/app/apps/github/src/inbox/count.ts +70 -0
- package/app/apps/github/src/inbox/inbox-item.tsx +66 -0
- package/app/apps/github/src/inbox/inbox-page.tsx +572 -0
- package/app/apps/github/src/inbox/marks.ts +130 -0
- package/app/apps/github/src/inbox/release-tags.ts +65 -0
- package/app/apps/github/src/inbox/search.ts +97 -0
- package/app/apps/github/src/inbox/subjects.ts +184 -0
- package/app/apps/github/src/inbox/subscription-controls.tsx +184 -0
- package/app/apps/github/src/inbox/subscriptions.ts +189 -0
- package/app/apps/github/src/inbox/threads.ts +198 -0
- package/app/apps/github/src/issues/changes.ts +332 -0
- package/app/apps/github/src/issues/counts.ts +62 -0
- package/app/apps/github/src/issues/issue-list.tsx +682 -0
- package/app/apps/github/src/issues/issue-page.tsx +533 -0
- package/app/apps/github/src/issues/issues.ts +566 -0
- package/app/apps/github/src/issues/label-dialog.tsx +310 -0
- package/app/apps/github/src/issues/labels-page.tsx +119 -0
- package/app/apps/github/src/issues/new-issue.tsx +79 -0
- package/app/apps/github/src/issues/parts.tsx +71 -0
- package/app/apps/github/src/issues/picker.tsx +298 -0
- package/app/apps/github/src/issues/search.ts +238 -0
- package/app/apps/github/src/issues/sidebar.tsx +236 -0
- package/app/apps/github/src/lib/cn.ts +8 -0
- package/app/apps/github/src/lib/highlighting.ts +13 -0
- package/app/apps/github/src/live/follow.ts +129 -0
- package/app/apps/github/src/live/sse.ts +74 -0
- package/app/apps/github/src/live/use-follow.ts +37 -0
- package/app/apps/github/src/markdown/README.md +53 -0
- package/app/apps/github/src/markdown/allowed-html.ts +69 -0
- package/app/apps/github/src/markdown/context.ts +206 -0
- package/app/apps/github/src/markdown/images.ts +81 -0
- package/app/apps/github/src/markdown/lookup.ts +122 -0
- package/app/apps/github/src/markdown/patches.ts +299 -0
- package/app/apps/github/src/markdown/query.ts +25 -0
- package/app/apps/github/src/markdown/references.ts +158 -0
- package/app/apps/github/src/markdown/render.ts +103 -0
- package/app/apps/github/src/names/owners.ts +51 -0
- package/app/apps/github/src/names/repos.ts +24 -0
- package/app/apps/github/src/palette/palette.tsx +547 -0
- package/app/apps/github/src/palette/recent.ts +116 -0
- package/app/apps/github/src/palette/rows.tsx +455 -0
- package/app/apps/github/src/palette/server.ts +104 -0
- package/app/apps/github/src/palette/targets.ts +306 -0
- package/app/apps/github/src/policy.ts +600 -0
- package/app/apps/github/src/private-repos.ts +47 -0
- package/app/apps/github/src/pulls/compare-page.tsx +342 -0
- package/app/apps/github/src/pulls/files-tab.tsx +776 -0
- package/app/apps/github/src/pulls/live.ts +124 -0
- package/app/apps/github/src/pulls/merge-box.tsx +367 -0
- package/app/apps/github/src/pulls/merge-button.ts +86 -0
- package/app/apps/github/src/pulls/pull-list.tsx +235 -0
- package/app/apps/github/src/pulls/pull-page.tsx +474 -0
- package/app/apps/github/src/pulls/pull.ts +468 -0
- package/app/apps/github/src/pulls/pulls.ts +318 -0
- package/app/apps/github/src/pulls/review.ts +350 -0
- package/app/apps/github/src/pulls/search.ts +130 -0
- package/app/apps/github/src/queue/queue-page.tsx +405 -0
- package/app/apps/github/src/queue/queue.ts +231 -0
- package/app/apps/github/src/releases/latest-release.tsx +55 -0
- package/app/apps/github/src/releases/overview.tsx +30 -0
- package/app/apps/github/src/releases/release-form.tsx +353 -0
- package/app/apps/github/src/releases/release-list.tsx +173 -0
- package/app/apps/github/src/releases/release-view.tsx +183 -0
- package/app/apps/github/src/releases/releases.ts +308 -0
- package/app/apps/github/src/releases/tag-list.tsx +134 -0
- package/app/apps/github/src/router.tsx +46 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +33 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/_code.tsx +11 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases.tsx +23 -0
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +39 -0
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +34 -0
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +42 -0
- package/app/apps/github/src/routes/$owner/$repo/compare/$.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +24 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +50 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +53 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +43 -0
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/checks.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/commits.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/files.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +52 -0
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +48 -0
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +58 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +40 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +35 -0
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +102 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/access.tsx +9 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +16 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/new.tsx +25 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +17 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/route.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/rules.tsx +12 -0
- package/app/apps/github/src/routes/$owner/$repo/tokens.tsx +16 -0
- package/app/apps/github/src/routes/$owner/index.tsx +45 -0
- package/app/apps/github/src/routes/-nav.tsx +293 -0
- package/app/apps/github/src/routes/-root-testing.ts +107 -0
- package/app/apps/github/src/routes/__root.tsx +225 -0
- package/app/apps/github/src/routes/api.auth.$.ts +18 -0
- package/app/apps/github/src/routes/downloads/$owner/$repo/$asset.tsx +10 -0
- package/app/apps/github/src/routes/file-icons[.]svg.ts +21 -0
- package/app/apps/github/src/routes/icons/$owner/$repo.tsx +14 -0
- package/app/apps/github/src/routes/icons/$owner/index.tsx +14 -0
- package/app/apps/github/src/routes/icons/index.tsx +12 -0
- package/app/apps/github/src/routes/index.tsx +48 -0
- package/app/apps/github/src/routes/login.tsx +24 -0
- package/app/apps/github/src/routes/login_.code.tsx +31 -0
- package/app/apps/github/src/routes/new.tsx +91 -0
- package/app/apps/github/src/routes/notifications.tsx +20 -0
- package/app/apps/github/src/routes/orgs/$owner/issues.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/releases.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +25 -0
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +30 -0
- package/app/apps/github/src/routes/orgs/$owner/tokens.tsx +15 -0
- package/app/apps/github/src/routes/settings.tsx +54 -0
- package/app/apps/github/src/routes/signup.tsx +24 -0
- package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +10 -0
- package/app/apps/github/src/seed/acme.ts +498 -0
- package/app/apps/github/src/seed/licenses.ts +114 -0
- package/app/apps/github/src/seed/seed.ts +538 -0
- package/app/apps/github/src/server.ts +97 -0
- package/app/apps/github/src/settings/account-avatar.tsx +43 -0
- package/app/apps/github/src/settings/avatar-section.tsx +140 -0
- package/app/apps/github/src/settings/avatar.ts +58 -0
- package/app/apps/github/src/settings/general-settings.tsx +439 -0
- package/app/apps/github/src/settings/general.ts +73 -0
- package/app/apps/github/src/settings/hook-form.tsx +195 -0
- package/app/apps/github/src/settings/hook-list.tsx +166 -0
- package/app/apps/github/src/settings/hooks.ts +87 -0
- package/app/apps/github/src/settings/org-settings.tsx +228 -0
- package/app/apps/github/src/settings/orgs.ts +116 -0
- package/app/apps/github/src/settings/rule-list.tsx +72 -0
- package/app/apps/github/src/settings/rules.ts +27 -0
- package/app/apps/github/src/settings/settings-layout.tsx +114 -0
- package/app/apps/github/src/signin/approval.ts +186 -0
- package/app/apps/github/src/signin/auth-client.ts +127 -0
- package/app/apps/github/src/signin/auth.ts +753 -0
- package/app/apps/github/src/signin/avatars.ts +126 -0
- package/app/apps/github/src/signin/client-ip.ts +39 -0
- package/app/apps/github/src/signin/credentials.ts +26 -0
- package/app/apps/github/src/signin/device-code.ts +95 -0
- package/app/apps/github/src/signin/device-prompt.ts +125 -0
- package/app/apps/github/src/signin/errors.ts +135 -0
- package/app/apps/github/src/signin/host-session.ts +68 -0
- package/app/apps/github/src/signin/orgs.ts +283 -0
- package/app/apps/github/src/signin/owner-names.ts +183 -0
- package/app/apps/github/src/signin/person-lock.ts +104 -0
- package/app/apps/github/src/signin/seal.ts +88 -0
- package/app/apps/github/src/signin/seed-people.ts +92 -0
- package/app/apps/github/src/signin/session.ts +48 -0
- package/app/apps/github/src/signin/unborn.ts +110 -0
- package/app/apps/github/src/signin/viewer-orgs.ts +47 -0
- package/app/apps/github/src/signin/viewer.ts +74 -0
- package/app/apps/github/src/signin/with-headers.ts +14 -0
- package/app/apps/github/src/tokens/tokens-page.tsx +529 -0
- package/app/apps/github/src/tokens/tokens.ts +54 -0
- package/app/apps/github/tsconfig.json +25 -0
- package/app/apps/github/tsconfig.worker.json +24 -0
- package/app/apps/github/vite.config.ts +21 -0
- package/app/pnpm-workspace.yaml +216 -0
- package/app/tsconfig.base.json +127 -0
- package/dist/LICENSE +202 -0
- package/dist/cli/child.mjs +42 -0
- package/dist/cli/commands.mjs +23 -0
- package/dist/cli/credentials.mjs +84 -0
- package/dist/cli/documents.mjs +214 -0
- package/dist/cli/events.mjs +55 -0
- package/dist/cli/failure.mjs +105 -0
- package/dist/cli/folders.mjs +32 -0
- package/dist/cli/git-remote-ref0.d.mts +1 -0
- package/dist/cli/git-remote-ref0.mjs +29 -0
- package/dist/cli/git.mjs +48 -0
- package/dist/cli/helpers.mjs +51 -0
- package/dist/cli/hosts.mjs +127 -0
- package/dist/cli/node.mjs +15 -0
- package/dist/cli/output.mjs +135 -0
- package/dist/cli/prompt.mjs +35 -0
- package/dist/cli/queue.mjs +215 -0
- package/dist/cli/ref0-git.d.mts +1 -0
- package/dist/cli/ref0-git.mjs +144 -0
- package/dist/cli/repos.mjs +162 -0
- package/dist/cli/resources.mjs +131 -0
- package/dist/cli/run-end.mjs +57 -0
- package/dist/cli/runtime.mjs +50 -0
- package/dist/cli/setup.mjs +1410 -0
- package/dist/cli/sign-in.mjs +162 -0
- package/dist/cli/sign-ins.mjs +79 -0
- package/dist/cli/sqlite.mjs +28 -0
- package/dist/cli/tokens.mjs +141 -0
- package/dist/cli/vendor.mjs +123 -0
- package/dist/init/app.mjs +231 -0
- package/dist/init/astro.mjs +49 -0
- package/dist/init/choices.mjs +497 -0
- package/dist/init/cloudflare.mjs +324 -0
- package/dist/init/create.mjs +151 -0
- package/dist/init/detect.mjs +297 -0
- package/dist/init/files.mjs +75 -0
- package/dist/init/frameworks.mjs +248 -0
- package/dist/init/git-module.mjs +49 -0
- package/dist/init/github-routes.mjs +66 -0
- package/dist/init/jsonc.mjs +143 -0
- package/dist/init/metadata.mjs +48 -0
- package/dist/init/mounts.mjs +109 -0
- package/dist/init/next.mjs +205 -0
- package/dist/init/node-app.mjs +189 -0
- package/dist/init/node.mjs +458 -0
- package/dist/init/nuxt.mjs +115 -0
- package/dist/init/output.mjs +21 -0
- package/dist/init/plan.mjs +82 -0
- package/dist/init/range-major.mjs +257 -0
- package/dist/init/react-router.mjs +59 -0
- package/dist/init/routes.mjs +148 -0
- package/dist/init/shell.mjs +4 -0
- package/dist/init/stores.mjs +51 -0
- package/dist/init/sveltekit.mjs +139 -0
- package/dist/init/template.mjs +142 -0
- package/dist/init/templates.mjs +343 -0
- package/dist/init/vercel.mjs +383 -0
- package/dist/init/versions.mjs +32 -0
- package/dist/init/workspace.mjs +20 -0
- package/package.json +48 -6
- package/README.md +0 -5
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import type { components } from '@octokit/openapi-types';
|
|
2
|
+
import { queryOptions } from '@tanstack/react-query';
|
|
3
|
+
|
|
4
|
+
import { github, raw } from '../clients/clients.ts';
|
|
5
|
+
import { nameOf, rawHref, type RepoPlace } from './places.ts';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A file's page reads the file through the contents API, which carries its bytes up to 1 MiB and
|
|
9
|
+
* past that only its size: a 50 MB file costs the page one small answer. Anything the reader
|
|
10
|
+
* downloads, or an image too big for that answer, is read raw through the REST client, with the
|
|
11
|
+
* viewer's session. An LFS file's object is read from the raw route through the app's proxy, as
|
|
12
|
+
* the viewer (Q506), and shown or saved from its bytes, never from the route's URL (Q310).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** The most bytes the contents API's answer carries: past it, a file is too big to show. */
|
|
16
|
+
export const shownBytesMost = 1024 * 1024;
|
|
17
|
+
|
|
18
|
+
/** The most bytes an image may hold for the page to read it raw and show it. */
|
|
19
|
+
export const imageBytesMost = 10 * 1024 * 1024;
|
|
20
|
+
|
|
21
|
+
/** The bytes Git, and GitHub, read to tell a binary file by a NUL. */
|
|
22
|
+
const sniffedBytes = 8000;
|
|
23
|
+
|
|
24
|
+
/** The images the page shows from their bytes, by extension. Never SVG, which can run script. */
|
|
25
|
+
const imageTypes: ReadonlyMap<string, string> = new Map([
|
|
26
|
+
['png', 'image/png'],
|
|
27
|
+
['jpg', 'image/jpeg'],
|
|
28
|
+
['jpeg', 'image/jpeg'],
|
|
29
|
+
['gif', 'image/gif'],
|
|
30
|
+
['webp', 'image/webp'],
|
|
31
|
+
['avif', 'image/avif'],
|
|
32
|
+
['bmp', 'image/bmp'],
|
|
33
|
+
['ico', 'image/x-icon'],
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
/** The image type a file's name says it holds, or `undefined`. */
|
|
37
|
+
export const imageTypeOf = (path: string) => {
|
|
38
|
+
const name = nameOf(path);
|
|
39
|
+
const dot = name.lastIndexOf('.');
|
|
40
|
+
|
|
41
|
+
return dot <= 0 ? undefined : imageTypes.get(name.slice(dot + 1).toLowerCase());
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** What a file's page shows of it. */
|
|
45
|
+
export type Shown =
|
|
46
|
+
| { readonly kind: 'text'; readonly text: string }
|
|
47
|
+
| {
|
|
48
|
+
readonly kind: 'image';
|
|
49
|
+
readonly type: string;
|
|
50
|
+
readonly bytes: Uint8Array<ArrayBuffer> | undefined;
|
|
51
|
+
}
|
|
52
|
+
| { readonly kind: 'binary' }
|
|
53
|
+
| { readonly kind: 'symlink'; readonly target: string }
|
|
54
|
+
| { readonly kind: 'tooBig' }
|
|
55
|
+
| { readonly kind: 'tooBigToRead' };
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A Git LFS file's object: its size, and whether the bucket holds it, `undefined` until the page
|
|
59
|
+
* reads it. Without it, the raw route answers the pointer, and the page shows that.
|
|
60
|
+
*/
|
|
61
|
+
export interface LfsObject {
|
|
62
|
+
readonly size: number;
|
|
63
|
+
readonly stored: boolean | undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* A file at a commit: its blob's ID, its size, and what its page shows, of its LFS object when it
|
|
68
|
+
* has one. A file past what the drop-in reads in one call, 16 MiB (#287), comes with neither ID
|
|
69
|
+
* nor size: it's `tooBigToRead`.
|
|
70
|
+
*/
|
|
71
|
+
export interface FileAt {
|
|
72
|
+
readonly path: string;
|
|
73
|
+
readonly commit: string;
|
|
74
|
+
readonly sha: string;
|
|
75
|
+
readonly size: number | undefined;
|
|
76
|
+
readonly lfs?: LfsObject;
|
|
77
|
+
readonly shown: Shown;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const bytesOf = (base64: string) =>
|
|
81
|
+
Uint8Array.from(atob(base64.replace(/\s/g, '')), (char) => char.charCodeAt(0));
|
|
82
|
+
|
|
83
|
+
/** A Git LFS pointer's object size, or `undefined` for a file that isn't one. */
|
|
84
|
+
export const lfsSize = (text: string) => {
|
|
85
|
+
if (!text.startsWith('version https://git-lfs.github.com/spec/v1\n')) return undefined;
|
|
86
|
+
|
|
87
|
+
const size = /^size (\d+)$/m.exec(text)?.[1];
|
|
88
|
+
|
|
89
|
+
return size === undefined ? undefined : Number(size);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** What the page shows of a file whose bytes it holds. */
|
|
93
|
+
export const shownOf = (path: string, bytes: Uint8Array<ArrayBuffer>): Shown => {
|
|
94
|
+
const isBinary = bytes.subarray(0, sniffedBytes).includes(0);
|
|
95
|
+
const text = isBinary ? '' : new TextDecoder().decode(bytes);
|
|
96
|
+
|
|
97
|
+
const type = imageTypeOf(path);
|
|
98
|
+
if (type !== undefined) return { kind: 'image', type, bytes };
|
|
99
|
+
|
|
100
|
+
return isBinary ? { kind: 'binary' } : { kind: 'text', text };
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** What the page shows of a file too big for the contents API to carry its bytes. */
|
|
104
|
+
const shownWithout = (path: string, size: number): Shown => {
|
|
105
|
+
const type = imageTypeOf(path);
|
|
106
|
+
|
|
107
|
+
return type !== undefined && size <= imageBytesMost
|
|
108
|
+
? { kind: 'image', type, bytes: undefined }
|
|
109
|
+
: { kind: 'tooBig' };
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** The drop-in's raw route's answer for `path` at `commit`, read as the viewer. */
|
|
113
|
+
const rawAnswer = async (place: RepoPlace, commit: string, path: string) => {
|
|
114
|
+
const answer = await raw(rawHref(place, commit, path));
|
|
115
|
+
if (!answer.ok) throw new Error(`The file didn't download (${answer.status})`);
|
|
116
|
+
|
|
117
|
+
return answer;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** The bytes the drop-in's raw route answers for `path` at `commit`, read as the viewer. */
|
|
121
|
+
export const rawBytes = async (place: RepoPlace, commit: string, path: string) =>
|
|
122
|
+
(await rawAnswer(place, commit, path)).blob();
|
|
123
|
+
|
|
124
|
+
/** `answer`'s body when it holds at most `most` bytes; `undefined` past them, the rest unread. */
|
|
125
|
+
const bodyUpTo = async (answer: Response, most: number) => {
|
|
126
|
+
const reader = answer.body?.getReader();
|
|
127
|
+
const pieces: Uint8Array[] = [];
|
|
128
|
+
let read = 0;
|
|
129
|
+
|
|
130
|
+
while (reader !== undefined) {
|
|
131
|
+
const piece = await reader.read();
|
|
132
|
+
if (piece.done) break;
|
|
133
|
+
|
|
134
|
+
read += piece.value.length;
|
|
135
|
+
|
|
136
|
+
if (read > most) {
|
|
137
|
+
await reader.cancel();
|
|
138
|
+
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
pieces.push(piece.value);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const bytes = new Uint8Array(read);
|
|
146
|
+
let at = 0;
|
|
147
|
+
|
|
148
|
+
for (const piece of pieces) {
|
|
149
|
+
bytes.set(piece, at);
|
|
150
|
+
at += piece.length;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return bytes;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* An LFS file's object, read whole when the page can show it: up to `shownBytesMost`, or its
|
|
158
|
+
* pointer, as the raw route answers when the bucket lacks the object. A bigger object is shown as
|
|
159
|
+
* its size says, an image read once the page draws it, and anything else saved. The pointer's size
|
|
160
|
+
* is the pusher's word, so the read stops at `shownBytesMost` whatever it says.
|
|
161
|
+
*/
|
|
162
|
+
const objectAt = async (
|
|
163
|
+
place: RepoPlace,
|
|
164
|
+
at: Omit<FileAt, 'shown' | 'lfs'>,
|
|
165
|
+
size: number,
|
|
166
|
+
pointer: Shown & { readonly kind: 'text' },
|
|
167
|
+
): Promise<FileAt> => {
|
|
168
|
+
if (size > shownBytesMost) {
|
|
169
|
+
return { ...at, lfs: { size, stored: undefined }, shown: shownWithout(at.path, size) };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const bytes = await bodyUpTo(await rawAnswer(place, at.commit, at.path), shownBytesMost);
|
|
173
|
+
if (bytes === undefined) return { ...at, lfs: { size, stored: true }, shown: { kind: 'tooBig' } };
|
|
174
|
+
|
|
175
|
+
const stored = new TextDecoder().decode(bytes) !== pointer.text;
|
|
176
|
+
|
|
177
|
+
return { ...at, lfs: { size, stored }, shown: stored ? shownOf(at.path, bytes) : pointer };
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* A path's answer from the contents API, or the README's: a file, a link or a submodule, or the
|
|
182
|
+
* tree the API's `object` media type answers, which its type admits beside them.
|
|
183
|
+
*/
|
|
184
|
+
type ContentAnswer =
|
|
185
|
+
| components['schemas']['content-tree']
|
|
186
|
+
| components['schemas']['content-file']
|
|
187
|
+
| components['schemas']['content-symlink']
|
|
188
|
+
| components['schemas']['content-submodule'];
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The file `answer` gives for `path` in the commit `commit`, or `null` where it's no file. An LFS
|
|
192
|
+
* pointer costs a call, for its object.
|
|
193
|
+
*/
|
|
194
|
+
const fileOf = async (
|
|
195
|
+
place: RepoPlace,
|
|
196
|
+
commit: string,
|
|
197
|
+
path: string,
|
|
198
|
+
answer: ContentAnswer,
|
|
199
|
+
): Promise<FileAt | null> => {
|
|
200
|
+
const at = { path, commit, sha: answer.sha, size: answer.size };
|
|
201
|
+
|
|
202
|
+
if (answer.type === 'symlink' && 'target' in answer) {
|
|
203
|
+
return { ...at, shown: { kind: 'symlink', target: answer.target } };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (answer.type !== 'file') return null;
|
|
207
|
+
|
|
208
|
+
const content = 'content' in answer ? (answer.content ?? '') : '';
|
|
209
|
+
const carried =
|
|
210
|
+
'encoding' in answer && answer.encoding === 'base64' && answer.size <= shownBytesMost;
|
|
211
|
+
if (!carried) return { ...at, shown: shownWithout(path, answer.size) };
|
|
212
|
+
|
|
213
|
+
const bytes = bytesOf(content);
|
|
214
|
+
const pointer = new TextDecoder().decode(bytes);
|
|
215
|
+
const size = lfsSize(pointer);
|
|
216
|
+
if (size === undefined) return { ...at, shown: shownOf(path, bytes) };
|
|
217
|
+
|
|
218
|
+
return objectAt(place, at, size, { kind: 'text', text: pointer });
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The file at `path` in the commit `commit`: one call, or `null` where no file is. An LFS pointer
|
|
223
|
+
* costs a second, for its object.
|
|
224
|
+
*/
|
|
225
|
+
export const fileAt = (place: RepoPlace, commit: string, path: string) =>
|
|
226
|
+
queryOptions({
|
|
227
|
+
queryKey: ['file', place.owner, place.repo, commit, path],
|
|
228
|
+
queryFn: async (): Promise<FileAt | null> => {
|
|
229
|
+
const answer = await github.GET('/repos/{owner}/{repo}/contents/{path}', {
|
|
230
|
+
params: { path: { ...place, path }, query: { ref: commit } },
|
|
231
|
+
});
|
|
232
|
+
if (answer.response.status === 404) return null;
|
|
233
|
+
|
|
234
|
+
if (answer.response.status === 413) {
|
|
235
|
+
return { path, commit, sha: '', size: undefined, shown: { kind: 'tooBigToRead' } };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (answer.data === undefined) {
|
|
239
|
+
throw new Error(`The file didn't load (${answer.response.status})`);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return Array.isArray(answer.data) ? null : fileOf(place, commit, path, answer.data);
|
|
243
|
+
},
|
|
244
|
+
staleTime: Infinity,
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* The README the drop-in finds at the default branch, as `GET /repos/{owner}/{repo}/readme`
|
|
249
|
+
* answers it, read beside the home's head commit and root: `null` where it finds none, refuses or
|
|
250
|
+
* fails. Its answer never goes stale, since `readmeAt` draws it only where the root the home draws
|
|
251
|
+
* lists that same file, by its blob's ID.
|
|
252
|
+
*/
|
|
253
|
+
export const readmeNow = (place: RepoPlace) =>
|
|
254
|
+
queryOptions({
|
|
255
|
+
queryKey: ['readme', place.owner, place.repo],
|
|
256
|
+
queryFn: async () => {
|
|
257
|
+
const answer = await github.GET('/repos/{owner}/{repo}/readme', { params: { path: place } });
|
|
258
|
+
|
|
259
|
+
return answer.data ?? null;
|
|
260
|
+
},
|
|
261
|
+
staleTime: Infinity,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* The README `named` at `commit`, as `fileAt` reads it, from `early`, the default branch's
|
|
266
|
+
* `readmeNow`, when it's the same file: the root's own pick, and the same blob. A README another
|
|
267
|
+
* push changed, or the drop-in picked among two, is read at the commit, as without it.
|
|
268
|
+
*/
|
|
269
|
+
export const readmeAt = async (
|
|
270
|
+
place: RepoPlace,
|
|
271
|
+
commit: string,
|
|
272
|
+
named: { readonly path: string; readonly sha: string },
|
|
273
|
+
early: ContentAnswer | null,
|
|
274
|
+
) => {
|
|
275
|
+
const same = early !== null && early.path === named.path && early.sha === named.sha;
|
|
276
|
+
|
|
277
|
+
return same ? fileOf(place, commit, named.path, early) : undefined;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/** A blob's bytes, read raw through the REST client as the viewer. */
|
|
281
|
+
const blobBytes = async (place: RepoPlace, sha: string) => {
|
|
282
|
+
const answer = await github.GET('/repos/{owner}/{repo}/git/blobs/{file_sha}', {
|
|
283
|
+
params: { path: { ...place, file_sha: sha } },
|
|
284
|
+
headers: { accept: 'application/vnd.github.raw' },
|
|
285
|
+
parseAs: 'blob',
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
if (answer.data === undefined) {
|
|
289
|
+
throw new Error(`The file didn't download (${answer.response.status})`);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return answer.data;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* A file's whole bytes, for a download or an image: an LFS file's object as the raw route answers
|
|
297
|
+
* it, its pointer when the bucket lacks it, and any other file's blob.
|
|
298
|
+
*/
|
|
299
|
+
export const fileBytes = (place: RepoPlace, file: FileAt) =>
|
|
300
|
+
file.lfs === undefined ? blobBytes(place, file.sha) : rawBytes(place, file.commit, file.path);
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* The bytes of an image too big for the contents API, up to `imageBytesMost`. An LFS image whose
|
|
304
|
+
* object isn't stored fails, as an image that didn't load, which the page offers to download.
|
|
305
|
+
*/
|
|
306
|
+
export const imageBytes = (place: RepoPlace, file: FileAt) =>
|
|
307
|
+
queryOptions({
|
|
308
|
+
queryKey: ['image', place.owner, place.repo, file.commit, file.path],
|
|
309
|
+
queryFn: async () => {
|
|
310
|
+
const bytes = new Uint8Array(await (await fileBytes(place, file)).arrayBuffer());
|
|
311
|
+
|
|
312
|
+
if (file.lfs !== undefined && bytes.length !== file.lfs.size) {
|
|
313
|
+
throw new Error("Its Git LFS object isn't stored");
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return bytes;
|
|
317
|
+
},
|
|
318
|
+
staleTime: Infinity,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Saves `bytes` as `name`: the app names the download from the file's path, never from the raw
|
|
323
|
+
* route, and the browser saves it rather than opening it.
|
|
324
|
+
*/
|
|
325
|
+
export const save = (bytes: Blob, name: string) => {
|
|
326
|
+
const url = URL.createObjectURL(new Blob([bytes], { type: 'application/octet-stream' }));
|
|
327
|
+
const link = document.createElement('a');
|
|
328
|
+
link.href = url;
|
|
329
|
+
link.download = name;
|
|
330
|
+
link.click();
|
|
331
|
+
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
332
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { useState, type ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
FileIcon,
|
|
5
|
+
FolderIcon,
|
|
6
|
+
SubmoduleIcon,
|
|
7
|
+
SymlinkIcon,
|
|
8
|
+
} from '../components/file-icons/file-icons.tsx';
|
|
9
|
+
import { Button } from '../components/ui/button.tsx';
|
|
10
|
+
import { Card, CardFooter } from '../components/ui/card.tsx';
|
|
11
|
+
import { Table, TableBody, TableCell, TableRow } from '../components/ui/table.tsx';
|
|
12
|
+
import { Go } from './controls.tsx';
|
|
13
|
+
import { blobHref, parentOf, treeHref, type At } from './places.ts';
|
|
14
|
+
import type { Entry, Folder } from './trees.ts';
|
|
15
|
+
|
|
16
|
+
/** The rows a folder draws at first: a folder of 10,000 files draws the rest when asked. */
|
|
17
|
+
export const rowsFirst = 1000;
|
|
18
|
+
|
|
19
|
+
/** A row's one cell, which keeps a long name to the table's width on a phone. */
|
|
20
|
+
const cell = 'max-w-0 p-0';
|
|
21
|
+
|
|
22
|
+
const link = 'pressable pressable-row flex min-w-0 items-center gap-2.5 px-3 py-2 text-sm';
|
|
23
|
+
|
|
24
|
+
/** A row's icon, a step up from the tree's 16px: 20px, beside the type scale's 14px names. */
|
|
25
|
+
const iconSize = 'size-5';
|
|
26
|
+
|
|
27
|
+
function EntryRow({ at, entry }: { readonly at: At; readonly entry: Entry }) {
|
|
28
|
+
// A file's icon is the tree's, coloured for its type; the rest are glyphs.
|
|
29
|
+
const icon = {
|
|
30
|
+
folder: <FolderIcon className={`${iconSize} text-link`} />,
|
|
31
|
+
file: <FileIcon path={entry.path} className={iconSize} />,
|
|
32
|
+
symlink: <SymlinkIcon className={iconSize} />,
|
|
33
|
+
submodule: <SubmoduleIcon className={iconSize} />,
|
|
34
|
+
}[entry.kind];
|
|
35
|
+
|
|
36
|
+
// A submodule is another repository's commit: the page has no URL for it, so it names it.
|
|
37
|
+
if (entry.kind === 'submodule') {
|
|
38
|
+
return (
|
|
39
|
+
<TableRow>
|
|
40
|
+
<TableCell className={cell}>
|
|
41
|
+
<span className={link}>
|
|
42
|
+
{icon}
|
|
43
|
+
<span className="truncate">{entry.name}</span>
|
|
44
|
+
<span className="font-mono text-muted-foreground">@ {entry.sha.slice(0, 7)}</span>
|
|
45
|
+
</span>
|
|
46
|
+
</TableCell>
|
|
47
|
+
</TableRow>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const href =
|
|
52
|
+
entry.kind === 'folder'
|
|
53
|
+
? treeHref(at, at.ref.name, entry.path)
|
|
54
|
+
: blobHref(at, at.ref.name, entry.path);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<TableRow>
|
|
58
|
+
<TableCell className={cell}>
|
|
59
|
+
<Go href={href} className={link}>
|
|
60
|
+
{icon}
|
|
61
|
+
<span className="truncate">{entry.name}</span>
|
|
62
|
+
</Go>
|
|
63
|
+
</TableCell>
|
|
64
|
+
</TableRow>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A folder's entries in a card, folders first, with a row up to its parent below the root, under
|
|
70
|
+
* `header` when the page gives one.
|
|
71
|
+
*/
|
|
72
|
+
export function FolderList({
|
|
73
|
+
at,
|
|
74
|
+
folder,
|
|
75
|
+
header,
|
|
76
|
+
}: {
|
|
77
|
+
readonly at: At;
|
|
78
|
+
readonly folder: Folder;
|
|
79
|
+
readonly header?: ReactNode;
|
|
80
|
+
}) {
|
|
81
|
+
const [all, setAll] = useState(false);
|
|
82
|
+
const shown = all ? folder.entries : folder.entries.slice(0, rowsFirst);
|
|
83
|
+
const hidden = folder.entries.length - shown.length;
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Card className="gap-0 py-0">
|
|
87
|
+
{header}
|
|
88
|
+
{folder.truncated && (
|
|
89
|
+
<p className="border-b bg-muted px-3 py-2 text-muted-foreground">
|
|
90
|
+
This folder holds more entries than the server lists: only the first are here.
|
|
91
|
+
</p>
|
|
92
|
+
)}
|
|
93
|
+
<Table aria-label="Folder">
|
|
94
|
+
<TableBody>
|
|
95
|
+
{folder.path !== '' && (
|
|
96
|
+
<TableRow>
|
|
97
|
+
<TableCell className={cell}>
|
|
98
|
+
<Go
|
|
99
|
+
href={treeHref(at, at.ref.name, parentOf(folder.path))}
|
|
100
|
+
aria-label="Parent folder"
|
|
101
|
+
className={`${link} text-muted-foreground`}
|
|
102
|
+
>
|
|
103
|
+
..
|
|
104
|
+
</Go>
|
|
105
|
+
</TableCell>
|
|
106
|
+
</TableRow>
|
|
107
|
+
)}
|
|
108
|
+
{shown.map((entry) => (
|
|
109
|
+
<EntryRow key={entry.path} at={at} entry={entry} />
|
|
110
|
+
))}
|
|
111
|
+
</TableBody>
|
|
112
|
+
</Table>
|
|
113
|
+
{hidden > 0 && (
|
|
114
|
+
<CardFooter className="p-2">
|
|
115
|
+
<Button variant="ghost" size="sm" onClick={() => setAll(true)}>
|
|
116
|
+
Show {hidden.toLocaleString('en')} more
|
|
117
|
+
</Button>
|
|
118
|
+
</CardFooter>
|
|
119
|
+
)}
|
|
120
|
+
</Card>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { ChevronDownIcon, SearchIcon } from 'lucide-react';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import { FileIcon } from '../components/file-icons/file-icons.tsx';
|
|
6
|
+
import { HotkeyHint, hotkeys } from '../components/hotkeys/hotkeys.tsx';
|
|
7
|
+
import { Alert, AlertDescription } from '../components/ui/alert.tsx';
|
|
8
|
+
import { Button } from '../components/ui/button.tsx';
|
|
9
|
+
import {
|
|
10
|
+
Combobox,
|
|
11
|
+
ComboboxContent,
|
|
12
|
+
ComboboxEmpty,
|
|
13
|
+
ComboboxInput,
|
|
14
|
+
ComboboxItem,
|
|
15
|
+
ComboboxList,
|
|
16
|
+
ComboboxTrigger,
|
|
17
|
+
} from '../components/ui/combobox.tsx';
|
|
18
|
+
import { Skeleton } from '../components/ui/skeleton.tsx';
|
|
19
|
+
import { Go } from './controls.tsx';
|
|
20
|
+
import { blobHref, type At } from './places.ts';
|
|
21
|
+
import { allFiles } from './trees.ts';
|
|
22
|
+
|
|
23
|
+
/** The most matches the list draws: the reader types more to narrow 100,000 paths. */
|
|
24
|
+
export const matchesMost = 50;
|
|
25
|
+
|
|
26
|
+
/** Paths holding each of `words`' characters in order, a file's name before a folder's. */
|
|
27
|
+
export const matching = (paths: readonly string[], words: string) => {
|
|
28
|
+
const wanted = words.toLowerCase().replace(/\s/g, '');
|
|
29
|
+
if (wanted === '') return paths.slice(0, matchesMost);
|
|
30
|
+
|
|
31
|
+
const holds = (path: string) => {
|
|
32
|
+
let at = 0;
|
|
33
|
+
|
|
34
|
+
for (const char of path.toLowerCase()) if (char === wanted[at]) at += 1;
|
|
35
|
+
|
|
36
|
+
return at === wanted.length;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const named = (path: string) =>
|
|
40
|
+
path
|
|
41
|
+
.slice(path.lastIndexOf('/') + 1)
|
|
42
|
+
.toLowerCase()
|
|
43
|
+
.includes(wanted);
|
|
44
|
+
const found = paths.filter(holds);
|
|
45
|
+
|
|
46
|
+
return [...found.filter(named), ...found.filter((path) => !named(path))].slice(0, matchesMost);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* What Go to file lists: the filter, every path read once, and the matches as links, which go
|
|
51
|
+
* there themselves, by a click or by Enter on the one highlighted, and close the list.
|
|
52
|
+
*/
|
|
53
|
+
function Finder({
|
|
54
|
+
files,
|
|
55
|
+
at,
|
|
56
|
+
onPick,
|
|
57
|
+
}: {
|
|
58
|
+
readonly files: ReturnType<typeof useAllFiles>;
|
|
59
|
+
readonly at: At;
|
|
60
|
+
readonly onPick: () => void;
|
|
61
|
+
}) {
|
|
62
|
+
return (
|
|
63
|
+
<>
|
|
64
|
+
<ComboboxInput showTrigger={false} aria-label="File path" placeholder="Go to file…" />
|
|
65
|
+
{files.isPending && <Skeleton className="m-1.5 h-24" />}
|
|
66
|
+
{files.error !== null && (
|
|
67
|
+
<Alert variant="destructive" className="m-1.5 w-auto">
|
|
68
|
+
<AlertDescription>{files.error.message}</AlertDescription>
|
|
69
|
+
</Alert>
|
|
70
|
+
)}
|
|
71
|
+
{files.data?.truncated === true && (
|
|
72
|
+
<p className="px-3.5 pt-1.5 text-meta text-muted-foreground">
|
|
73
|
+
This repository holds more files than the server lists: some aren't here.
|
|
74
|
+
</p>
|
|
75
|
+
)}
|
|
76
|
+
{files.isSuccess && <ComboboxEmpty>No file matches.</ComboboxEmpty>}
|
|
77
|
+
<ComboboxList aria-label="Files found">
|
|
78
|
+
{(path: string) => (
|
|
79
|
+
<ComboboxItem
|
|
80
|
+
key={path}
|
|
81
|
+
value={path}
|
|
82
|
+
render={<Go href={blobHref(at, at.ref.name, path)} onClick={onPick} />}
|
|
83
|
+
>
|
|
84
|
+
<FileIcon path={path} />
|
|
85
|
+
<span className="break-all">{path}</span>
|
|
86
|
+
</ComboboxItem>
|
|
87
|
+
)}
|
|
88
|
+
</ComboboxList>
|
|
89
|
+
</>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const useAllFiles = (at: At, root: string, open: boolean) =>
|
|
94
|
+
useQuery({ ...allFiles(at, root), enabled: open });
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Finds a file by its path. Every path costs one call, made only when the reader opens it: the
|
|
98
|
+
* tree's levels never need it.
|
|
99
|
+
*/
|
|
100
|
+
export function GoToFile({ at, root }: { readonly at: At; readonly root: string }) {
|
|
101
|
+
const [open, setOpen] = useState(false);
|
|
102
|
+
const [words, setWords] = useState('');
|
|
103
|
+
const files = useAllFiles(at, root, open);
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<Combobox
|
|
107
|
+
items={matching(files.data?.paths ?? [], words)}
|
|
108
|
+
filter={null}
|
|
109
|
+
inputValue={words}
|
|
110
|
+
onInputValueChange={setWords}
|
|
111
|
+
open={open}
|
|
112
|
+
onOpenChange={setOpen}
|
|
113
|
+
autoHighlight
|
|
114
|
+
>
|
|
115
|
+
<ComboboxTrigger
|
|
116
|
+
render={<Button variant="outline" size="lg" />}
|
|
117
|
+
chevron={false}
|
|
118
|
+
data-hotkey={`${hotkeys.files}, ${hotkeys.search}`}
|
|
119
|
+
>
|
|
120
|
+
<SearchIcon data-icon="inline-start" />
|
|
121
|
+
Go to file
|
|
122
|
+
<HotkeyHint keys={hotkeys.files}>
|
|
123
|
+
<ChevronDownIcon aria-hidden className="size-4 text-muted-foreground" />
|
|
124
|
+
</HotkeyHint>
|
|
125
|
+
</ComboboxTrigger>
|
|
126
|
+
<ComboboxContent aria-label="Go to file" align="end" className="w-96">
|
|
127
|
+
<Finder files={files} at={at} onPick={() => setOpen(false)} />
|
|
128
|
+
</ComboboxContent>
|
|
129
|
+
</Combobox>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { SelectedLineRange } from '@pierre/diffs';
|
|
2
|
+
import { File } from '@pierre/diffs/react';
|
|
3
|
+
import { useMemo, useRef } from 'react';
|
|
4
|
+
|
|
5
|
+
import { useTheme } from '../components/theme-provider.tsx';
|
|
6
|
+
import { linesOf, type LineRange } from './lines.ts';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A file's text drawn by `@pierre/diffs`' file view, highlighted by `@pierre/highlights`: its lines
|
|
10
|
+
* picked by their numbers, a click for one and a shift-click or a drag for a range, which the page
|
|
11
|
+
* links. The browser alone loads this, and Shiki's grammars with it. Its colours follow the theme
|
|
12
|
+
* picked: its own `system` follows the system's setting, which a pick of Light or Dark overrides.
|
|
13
|
+
*/
|
|
14
|
+
export default function Highlighted({
|
|
15
|
+
name,
|
|
16
|
+
text,
|
|
17
|
+
selected,
|
|
18
|
+
onSelect,
|
|
19
|
+
}: {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly text: string;
|
|
22
|
+
readonly selected: LineRange | undefined;
|
|
23
|
+
readonly onSelect: (range: LineRange | undefined) => void;
|
|
24
|
+
}) {
|
|
25
|
+
// Scrolled to once, when the lines first draw: a pick after that is already in view.
|
|
26
|
+
const scrolled = useRef(false);
|
|
27
|
+
const first = useRef(selected);
|
|
28
|
+
// Pierre draws a numbered empty line after a last newline, where the page counts none.
|
|
29
|
+
const file = useMemo(() => ({ name, contents: linesOf(text).join('\n') }), [name, text]);
|
|
30
|
+
const { theme } = useTheme();
|
|
31
|
+
const options = useMemo(
|
|
32
|
+
() => ({
|
|
33
|
+
themeType: theme,
|
|
34
|
+
disableFileHeader: true,
|
|
35
|
+
overflow: 'scroll' as const,
|
|
36
|
+
enableLineSelection: true,
|
|
37
|
+
onLineSelected: (range: SelectedLineRange | null) =>
|
|
38
|
+
onSelect(
|
|
39
|
+
range === null
|
|
40
|
+
? undefined
|
|
41
|
+
: { start: Math.min(range.start, range.end), end: Math.max(range.start, range.end) },
|
|
42
|
+
),
|
|
43
|
+
onPostRender: (node: HTMLElement) => {
|
|
44
|
+
const line = first.current?.start;
|
|
45
|
+
if (scrolled.current || line === undefined) return;
|
|
46
|
+
|
|
47
|
+
const row = (node.shadowRoot ?? node).querySelector(`[data-line="${line}"]`);
|
|
48
|
+
if (row === null) return;
|
|
49
|
+
|
|
50
|
+
scrolled.current = true;
|
|
51
|
+
row.scrollIntoView({ block: 'center' });
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
[onSelect, theme],
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return <File file={file} selectedLines={selected ?? null} options={options} />;
|
|
58
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A file's lines as its page links them, as GitHub writes a permalink: `#L10` for a line and
|
|
3
|
+
* `#L10-L20` for a range. The page reads the range from its URL's fragment and writes it back, in
|
|
4
|
+
* place, as the reader picks lines.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { highlightedCharsMost, highlightedLinesMost } from '#/lib/highlighting';
|
|
8
|
+
|
|
9
|
+
/** Lines `start` to `end`, counted from 1, `start` never past `end`. */
|
|
10
|
+
export interface LineRange {
|
|
11
|
+
readonly start: number;
|
|
12
|
+
readonly end: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The most lines whose numbers the plain view links, each a link of its own: past it, as a 1 MiB
|
|
17
|
+
* file may hold half a million lines, they're one text, and the page links none.
|
|
18
|
+
*/
|
|
19
|
+
export const linkedLinesMost = highlightedLinesMost;
|
|
20
|
+
|
|
21
|
+
/** `text`'s lines, without the empty one after a last newline. */
|
|
22
|
+
export const linesOf = (text: string) =>
|
|
23
|
+
(text.endsWith('\n') ? text.slice(0, -1) : text).split('\n');
|
|
24
|
+
|
|
25
|
+
/** The range a URL's fragment names, `#L10` or `#L10-L20`, either way round; `undefined` for any other. */
|
|
26
|
+
export const rangeOf = (fragment: string): LineRange | undefined => {
|
|
27
|
+
const named = /^#?L(\d+)(?:-L(\d+))?$/.exec(fragment);
|
|
28
|
+
if (named === null) return undefined;
|
|
29
|
+
|
|
30
|
+
const first = Number(named[1]);
|
|
31
|
+
const last = named[2] === undefined ? first : Number(named[2]);
|
|
32
|
+
if (first < 1 || last < 1) return undefined;
|
|
33
|
+
|
|
34
|
+
return { start: Math.min(first, last), end: Math.max(first, last) };
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** The fragment that links `range`: `#L10`, `#L10-L20`, or none. */
|
|
38
|
+
export const fragmentOf = (range: LineRange | undefined) => {
|
|
39
|
+
if (range === undefined) return '';
|
|
40
|
+
|
|
41
|
+
return range.start === range.end ? `#L${range.start}` : `#L${range.start}-L${range.end}`;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** Whether the page highlights `text`: within both bounds. */
|
|
45
|
+
export const isHighlighted = (text: string) =>
|
|
46
|
+
text.length <= highlightedCharsMost && linesOf(text).length <= highlightedLinesMost;
|