ref0-git 0.0.0-stage → 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 +52 -3
- package/README.md +0 -3
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { CheckIcon, PlusIcon, SettingsIcon, type LucideIcon } from 'lucide-react';
|
|
2
|
+
import { useState, type ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import { cn } from '#/lib/cn';
|
|
5
|
+
|
|
6
|
+
import { UserAvatar } from '../components/user-avatar.tsx';
|
|
7
|
+
import { Button } from '../components/ui/button.tsx';
|
|
8
|
+
import {
|
|
9
|
+
Combobox,
|
|
10
|
+
ComboboxContent,
|
|
11
|
+
ComboboxEmpty,
|
|
12
|
+
ComboboxInput,
|
|
13
|
+
ComboboxItem,
|
|
14
|
+
ComboboxList,
|
|
15
|
+
ComboboxTrigger,
|
|
16
|
+
} from '../components/ui/combobox.tsx';
|
|
17
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '../components/ui/tooltip.tsx';
|
|
18
|
+
import type { Label } from './issues.ts';
|
|
19
|
+
import { LabelDot } from './parts.tsx';
|
|
20
|
+
|
|
21
|
+
/** One thing a picker offers: what it saves, what it's found by, and how it's drawn. */
|
|
22
|
+
export interface Choice {
|
|
23
|
+
readonly value: string;
|
|
24
|
+
readonly label: string;
|
|
25
|
+
readonly drawn?: ReactNode;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** How a mark eases in when its row is picked: quickly, and not at all for reduced motion. */
|
|
29
|
+
const easing =
|
|
30
|
+
'transition-[scale,opacity] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A row's mark, on its left: a box that fills and ticks when several may be picked, or a ring
|
|
34
|
+
* that takes a dot when only one may be. Its row's `data-selected` draws it picked: Base UI writes
|
|
35
|
+
* it bare, which shadcn's `data-selected:` misses, since it asks for `"true"`.
|
|
36
|
+
*/
|
|
37
|
+
function Mark({ multiple }: { readonly multiple: boolean }) {
|
|
38
|
+
if (!multiple)
|
|
39
|
+
return (
|
|
40
|
+
<span
|
|
41
|
+
aria-hidden
|
|
42
|
+
className="grid size-4 shrink-0 place-items-center rounded-full border border-input group-data-[selected]/choice:border-primary dark:bg-input/30"
|
|
43
|
+
>
|
|
44
|
+
<span
|
|
45
|
+
className={cn(
|
|
46
|
+
'size-2 scale-0 rounded-full bg-primary opacity-0 group-data-[selected]/choice:scale-100 group-data-[selected]/choice:opacity-100',
|
|
47
|
+
easing,
|
|
48
|
+
)}
|
|
49
|
+
/>
|
|
50
|
+
</span>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<span
|
|
55
|
+
aria-hidden
|
|
56
|
+
className="relative grid size-4 shrink-0 place-items-center rounded-[4px] border border-input dark:bg-input/30"
|
|
57
|
+
>
|
|
58
|
+
<span
|
|
59
|
+
className={cn(
|
|
60
|
+
'absolute -inset-px scale-75 rounded-[4px] bg-primary opacity-0 group-data-[selected]/choice:scale-100 group-data-[selected]/choice:opacity-100',
|
|
61
|
+
easing,
|
|
62
|
+
)}
|
|
63
|
+
/>
|
|
64
|
+
<CheckIcon
|
|
65
|
+
className={cn(
|
|
66
|
+
// The row's highlight recolours what it holds; the tick stays on the box's fill.
|
|
67
|
+
'relative size-3.5 scale-50 text-primary-foreground! opacity-0 group-data-[selected]/choice:scale-100 group-data-[selected]/choice:opacity-100',
|
|
68
|
+
easing,
|
|
69
|
+
)}
|
|
70
|
+
/>
|
|
71
|
+
</span>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** A label as a picker's row draws it: a bigger dot, its name, and its description under it. */
|
|
76
|
+
export function LabelRow({ label }: { readonly label: Label }) {
|
|
77
|
+
return (
|
|
78
|
+
<span className="flex min-w-0 flex-1 items-start gap-2">
|
|
79
|
+
<LabelDot color={label.color} className="mt-0.5 size-3" />
|
|
80
|
+
<span className="flex min-w-0 flex-col">
|
|
81
|
+
<span className="truncate font-medium">{label.name}</span>
|
|
82
|
+
{label.description !== null && label.description !== '' && (
|
|
83
|
+
<span className="truncate text-muted-foreground">{label.description}</span>
|
|
84
|
+
)}
|
|
85
|
+
</span>
|
|
86
|
+
</span>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** A person as a picker's row draws them: their picture beside their login. */
|
|
91
|
+
export function PersonRow({ login }: { readonly login: string }) {
|
|
92
|
+
return (
|
|
93
|
+
<span className="flex min-w-0 items-center gap-2">
|
|
94
|
+
<UserAvatar login={login} size="sm" account="user" />
|
|
95
|
+
<span className="truncate">{login}</span>
|
|
96
|
+
</span>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* A row that stands for no one person, such as Anyone: a glyph in a circle the size of a picture,
|
|
102
|
+
* so its name lines up with the people's below it.
|
|
103
|
+
*/
|
|
104
|
+
export function StandInRow({
|
|
105
|
+
label,
|
|
106
|
+
icon: Icon,
|
|
107
|
+
}: {
|
|
108
|
+
readonly label: string;
|
|
109
|
+
readonly icon: LucideIcon;
|
|
110
|
+
}) {
|
|
111
|
+
return (
|
|
112
|
+
<span className="flex min-w-0 items-center gap-2">
|
|
113
|
+
<span
|
|
114
|
+
aria-hidden
|
|
115
|
+
className="grid size-6 shrink-0 place-items-center rounded-full bg-muted text-muted-foreground"
|
|
116
|
+
>
|
|
117
|
+
<Icon className="size-3.5" />
|
|
118
|
+
</span>
|
|
119
|
+
<span className="truncate">{label}</span>
|
|
120
|
+
</span>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** What a picker makes from what's typed, when nothing it offers has that name. */
|
|
125
|
+
export interface Making {
|
|
126
|
+
/** What it makes, as `Create label "docs"` names it. The picker closes as it's made. */
|
|
127
|
+
readonly what: string;
|
|
128
|
+
readonly make: (name: string) => void;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The value of a picker's last row, which makes what's typed: one no choice holds. */
|
|
132
|
+
const makingValue = '\u0000make';
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* A searchable picker under its button, `trigger`: each pick hands `onPick` the values `picked`
|
|
136
|
+
* then holds, several when `multiple`, or one, and `onClose` hears it close. With `making`, its
|
|
137
|
+
* list ends with a row that makes what's typed when nothing it offers has that name, and closes. It never
|
|
138
|
+
* waits on a save: a page shows each pick at once, and sends what it holds as it closes.
|
|
139
|
+
*
|
|
140
|
+
* A picker whose choices load as it opens hears it open with `onOpen`, and each search with
|
|
141
|
+
* `onType`, and says `reading` while none match yet.
|
|
142
|
+
*/
|
|
143
|
+
export function Picker({
|
|
144
|
+
name,
|
|
145
|
+
trigger,
|
|
146
|
+
choices,
|
|
147
|
+
picked,
|
|
148
|
+
multiple,
|
|
149
|
+
making,
|
|
150
|
+
reading,
|
|
151
|
+
onPick,
|
|
152
|
+
onOpen,
|
|
153
|
+
onType,
|
|
154
|
+
onClose,
|
|
155
|
+
}: {
|
|
156
|
+
readonly name: string;
|
|
157
|
+
/**
|
|
158
|
+
* The button: a text button with a chevron, as a list's filters are, or a gear icon button
|
|
159
|
+
* labelled `settings`, as a sidebar section's header ends in.
|
|
160
|
+
*/
|
|
161
|
+
readonly trigger: { readonly text: string } | { readonly settings: string };
|
|
162
|
+
readonly choices: readonly Choice[];
|
|
163
|
+
readonly picked: readonly string[];
|
|
164
|
+
readonly multiple: boolean;
|
|
165
|
+
readonly making?: Making | undefined;
|
|
166
|
+
/** What it says while nothing matches and more is still being read, such as `Searching…`. */
|
|
167
|
+
readonly reading?: string | undefined;
|
|
168
|
+
readonly onPick: (picked: readonly string[]) => void;
|
|
169
|
+
readonly onOpen?: (() => void) | undefined;
|
|
170
|
+
readonly onType?: ((typed: string) => void) | undefined;
|
|
171
|
+
readonly onClose?: (() => void) | undefined;
|
|
172
|
+
}) {
|
|
173
|
+
const [text, setText] = useState('');
|
|
174
|
+
const [open, setOpen] = useState(false);
|
|
175
|
+
const what = name.toLowerCase();
|
|
176
|
+
const typed = text.trim();
|
|
177
|
+
const named = choices.some((choice) => choice.label.toLowerCase() === typed.toLowerCase());
|
|
178
|
+
const maker =
|
|
179
|
+
making !== undefined && typed !== '' && !named
|
|
180
|
+
? { value: makingValue, label: `Create ${making.what} "${typed}"` }
|
|
181
|
+
: undefined;
|
|
182
|
+
const offered = maker === undefined ? choices : [...choices, maker];
|
|
183
|
+
// In the order `picked` holds them, so a pick only adds or drops one.
|
|
184
|
+
const chosen = picked.flatMap((value) => choices.filter((choice) => choice.value === value));
|
|
185
|
+
const make = (next: readonly Choice[]) => {
|
|
186
|
+
if (maker === undefined || !next.includes(maker)) return false;
|
|
187
|
+
|
|
188
|
+
// What's made takes over from the picker, such as a label's Dialog, so the picker closes.
|
|
189
|
+
setText('');
|
|
190
|
+
setOpen(false);
|
|
191
|
+
onClose?.();
|
|
192
|
+
making?.make(typed);
|
|
193
|
+
|
|
194
|
+
return true;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const shared = {
|
|
198
|
+
items: offered,
|
|
199
|
+
// Typing highlights the first match, so Enter picks it, or makes what's typed.
|
|
200
|
+
autoHighlight: true,
|
|
201
|
+
inputValue: text,
|
|
202
|
+
onInputValueChange: (next: string) => {
|
|
203
|
+
setText(next);
|
|
204
|
+
onType?.(next);
|
|
205
|
+
},
|
|
206
|
+
open,
|
|
207
|
+
onOpenChange: (next: boolean) => {
|
|
208
|
+
setOpen(next);
|
|
209
|
+
|
|
210
|
+
if (next) onOpen?.();
|
|
211
|
+
else onClose?.();
|
|
212
|
+
},
|
|
213
|
+
itemToStringLabel: (choice: Choice) => choice.label,
|
|
214
|
+
isItemEqualToValue: (one: Choice, other: Choice) => one.value === other.value,
|
|
215
|
+
// The making row names what's typed, so it always matches it.
|
|
216
|
+
filter: (choice: Choice, query: string) =>
|
|
217
|
+
choice === maker || choice.label.toLowerCase().includes(query.trim().toLowerCase()),
|
|
218
|
+
};
|
|
219
|
+
const parts = (
|
|
220
|
+
<>
|
|
221
|
+
{'text' in trigger ? (
|
|
222
|
+
<ComboboxTrigger render={<Button variant="ghost" size="sm" />} className="gap-1">
|
|
223
|
+
{trigger.text}
|
|
224
|
+
</ComboboxTrigger>
|
|
225
|
+
) : (
|
|
226
|
+
// An icon button names itself in the tooltip every icon button has.
|
|
227
|
+
<Tooltip>
|
|
228
|
+
<TooltipTrigger
|
|
229
|
+
render={
|
|
230
|
+
<ComboboxTrigger
|
|
231
|
+
render={<Button variant="ghost" size="icon-sm" aria-label={trigger.settings} />}
|
|
232
|
+
chevron={false}
|
|
233
|
+
/>
|
|
234
|
+
}
|
|
235
|
+
>
|
|
236
|
+
<SettingsIcon aria-hidden className="text-muted-foreground" />
|
|
237
|
+
</TooltipTrigger>
|
|
238
|
+
<TooltipContent>{trigger.settings}</TooltipContent>
|
|
239
|
+
</Tooltip>
|
|
240
|
+
)}
|
|
241
|
+
<ComboboxContent
|
|
242
|
+
aria-label={name}
|
|
243
|
+
align="end"
|
|
244
|
+
// A phone narrower than the minimum gets the width it has.
|
|
245
|
+
className="w-auto max-w-[min(22rem,var(--available-width))] min-w-[min(18rem,var(--available-width))]"
|
|
246
|
+
>
|
|
247
|
+
<ComboboxInput
|
|
248
|
+
showTrigger={false}
|
|
249
|
+
aria-label={`Filter ${what}`}
|
|
250
|
+
placeholder={`Filter ${what}`}
|
|
251
|
+
/>
|
|
252
|
+
<ComboboxEmpty>
|
|
253
|
+
{reading ?? (choices.length === 0 ? `No ${what} yet.` : `No ${what} match.`)}
|
|
254
|
+
</ComboboxEmpty>
|
|
255
|
+
<ComboboxList>
|
|
256
|
+
{(choice: Choice) => (
|
|
257
|
+
<ComboboxItem
|
|
258
|
+
key={choice.value}
|
|
259
|
+
value={choice}
|
|
260
|
+
showIndicator={false}
|
|
261
|
+
className="group/choice gap-2.5 pr-2"
|
|
262
|
+
>
|
|
263
|
+
{choice === maker ? (
|
|
264
|
+
<PlusIcon aria-hidden className="text-muted-foreground" />
|
|
265
|
+
) : (
|
|
266
|
+
<Mark multiple={multiple} />
|
|
267
|
+
)}
|
|
268
|
+
{choice.drawn ?? <span className="min-w-0 truncate">{choice.label}</span>}
|
|
269
|
+
</ComboboxItem>
|
|
270
|
+
)}
|
|
271
|
+
</ComboboxList>
|
|
272
|
+
</ComboboxContent>
|
|
273
|
+
</>
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
return multiple ? (
|
|
277
|
+
<Combobox
|
|
278
|
+
{...shared}
|
|
279
|
+
multiple
|
|
280
|
+
value={chosen}
|
|
281
|
+
onValueChange={(next: Choice[]) => {
|
|
282
|
+
if (!make(next)) onPick(next.map((choice) => choice.value));
|
|
283
|
+
}}
|
|
284
|
+
>
|
|
285
|
+
{parts}
|
|
286
|
+
</Combobox>
|
|
287
|
+
) : (
|
|
288
|
+
<Combobox
|
|
289
|
+
{...shared}
|
|
290
|
+
value={chosen[0] ?? null}
|
|
291
|
+
onValueChange={(next: Choice | null) => {
|
|
292
|
+
if (next !== null && !make([next])) onPick([next.value]);
|
|
293
|
+
}}
|
|
294
|
+
>
|
|
295
|
+
{parts}
|
|
296
|
+
</Combobox>
|
|
297
|
+
);
|
|
298
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The issue list's search box, as GitHub's reads it: qualifiers such as `is:open`, `label:bug`
|
|
3
|
+
* and `milestone:"v1.0"`, each one of its list's filters, and words of text, which the drop-in's
|
|
4
|
+
* search matches (#591). A qualifier neither takes is kept to say it filters nothing (Q514).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { RepoPlace } from '../code/places.ts';
|
|
8
|
+
|
|
9
|
+
/** Which issues the list shows. */
|
|
10
|
+
export type IssueState = 'open' | 'closed' | 'all';
|
|
11
|
+
|
|
12
|
+
/** Whom an issue is assigned to, or which milestone it's in: one by name, or none. */
|
|
13
|
+
export type Chosen = { readonly kind: 'named'; readonly name: string } | { readonly kind: 'none' };
|
|
14
|
+
|
|
15
|
+
/** What the list asks the drop-in for. */
|
|
16
|
+
export interface IssueFilter {
|
|
17
|
+
readonly state: IssueState;
|
|
18
|
+
readonly labels: readonly string[];
|
|
19
|
+
readonly milestone: Chosen | undefined;
|
|
20
|
+
readonly assignee: Chosen | undefined;
|
|
21
|
+
readonly author: string | undefined;
|
|
22
|
+
readonly order: 'newest' | 'oldest';
|
|
23
|
+
/** The box's words of text, as written, such as `crash` or `"on start"`, which only search matches. */
|
|
24
|
+
readonly words: readonly string[];
|
|
25
|
+
/** The qualifiers the box held that no filter takes, as written, such as `language:go`. */
|
|
26
|
+
readonly unfiltered: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The box's text when the list opens, as GitHub's has it. */
|
|
30
|
+
export const defaultQuery = 'is:issue is:open';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A term: `name:value`, `name:"a value"`, or a word, each perhaps quoted. Within quotes, a
|
|
34
|
+
* backslash escapes the character after it, so a name may hold a quote, and one that ends the text
|
|
35
|
+
* is itself: a quote never closed runs to the end of the text.
|
|
36
|
+
*/
|
|
37
|
+
const term = /(?:([a-z-]+):)?(?:"((?:[^"\\]|\\.|\\$)*)"?|(\S+))/gy;
|
|
38
|
+
|
|
39
|
+
/** A quoted value's text, its escapes undone. */
|
|
40
|
+
const unquoted = (quoted: string) => quoted.replaceAll(/\\(.)/gs, '$1');
|
|
41
|
+
|
|
42
|
+
const space = /\s+/y;
|
|
43
|
+
|
|
44
|
+
/** A term of the box's text: as written, where it starts, and its qualifier's name and value. */
|
|
45
|
+
export interface Term {
|
|
46
|
+
readonly written: string;
|
|
47
|
+
readonly at: number;
|
|
48
|
+
readonly name?: string;
|
|
49
|
+
readonly value: string;
|
|
50
|
+
/** Its quote is never closed, so it runs to the end of the text, whatever follows it. */
|
|
51
|
+
readonly open: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The terms of `query`, each as written, where it starts, and its qualifier's name and value. */
|
|
55
|
+
export const termsOf = (query: string) => {
|
|
56
|
+
const terms: Term[] = [];
|
|
57
|
+
let at = 0;
|
|
58
|
+
|
|
59
|
+
while (at < query.length) {
|
|
60
|
+
space.lastIndex = at;
|
|
61
|
+
|
|
62
|
+
if (space.exec(query) !== null) at = space.lastIndex;
|
|
63
|
+
|
|
64
|
+
if (at >= query.length) break;
|
|
65
|
+
|
|
66
|
+
term.lastIndex = at;
|
|
67
|
+
const found = term.exec(query);
|
|
68
|
+
if (found === null) break;
|
|
69
|
+
|
|
70
|
+
const [written, name, quoted, plain] = found;
|
|
71
|
+
const value = quoted === undefined ? (plain ?? '') : unquoted(quoted);
|
|
72
|
+
// A quoted term no longer than its `name:`, its opening quote and its value has no close.
|
|
73
|
+
const prefix = name === undefined ? 0 : name.length + 1;
|
|
74
|
+
const open = quoted !== undefined && written.length === prefix + 1 + quoted.length;
|
|
75
|
+
terms.push(
|
|
76
|
+
name === undefined ? { written, at, value, open } : { written, at, name, value, open },
|
|
77
|
+
);
|
|
78
|
+
at = term.lastIndex;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return terms;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/** A stretch of the box's text, and whether it's a qualifier's value a filter takes. */
|
|
85
|
+
export interface Stretch {
|
|
86
|
+
readonly text: string;
|
|
87
|
+
readonly filter: boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The box's `text` in stretches, with each qualifier's value a filter takes apart: every term but
|
|
92
|
+
* those in `unfiltered`, what the list's filter leaves of `text`. The stretches together are `text`.
|
|
93
|
+
*/
|
|
94
|
+
export const stretchesOf = (text: string, unfiltered: readonly string[]) => {
|
|
95
|
+
const left = [...unfiltered];
|
|
96
|
+
const stretches: Stretch[] = [];
|
|
97
|
+
let from = 0;
|
|
98
|
+
|
|
99
|
+
for (const { written, at, name } of termsOf(text)) {
|
|
100
|
+
const leftAt = left.indexOf(written);
|
|
101
|
+
|
|
102
|
+
if (leftAt !== -1) {
|
|
103
|
+
left.splice(leftAt, 1);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (name === undefined) continue;
|
|
108
|
+
|
|
109
|
+
const value = at + name.length + 1;
|
|
110
|
+
stretches.push({ text: text.slice(from, value), filter: false });
|
|
111
|
+
stretches.push({ text: text.slice(value, at + written.length), filter: true });
|
|
112
|
+
from = at + written.length;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
stretches.push({ text: text.slice(from), filter: false });
|
|
116
|
+
|
|
117
|
+
return stretches.filter((stretch) => stretch.text !== '');
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const named = (name: string): Chosen => ({ kind: 'named', name });
|
|
121
|
+
|
|
122
|
+
/** The filter `query` names; what no filter takes is in `unfiltered`. */
|
|
123
|
+
export const filterOf = (query: string): IssueFilter => {
|
|
124
|
+
let state: IssueState = 'all';
|
|
125
|
+
const labels: string[] = [];
|
|
126
|
+
let milestone: Chosen | undefined;
|
|
127
|
+
let assignee: Chosen | undefined;
|
|
128
|
+
let author: string | undefined;
|
|
129
|
+
let order: IssueFilter['order'] = 'newest';
|
|
130
|
+
const words: string[] = [];
|
|
131
|
+
const unfiltered: string[] = [];
|
|
132
|
+
|
|
133
|
+
for (const { written, name, value } of termsOf(query)) {
|
|
134
|
+
if (name === 'is' && (value === 'open' || value === 'closed')) state = value;
|
|
135
|
+
else if (name === 'is' && value === 'issue') continue;
|
|
136
|
+
else if (name === 'state' && (value === 'open' || value === 'closed')) state = value;
|
|
137
|
+
else if (name === 'label' && value !== '') labels.push(value);
|
|
138
|
+
else if (name === 'milestone' && value !== '') milestone = named(value);
|
|
139
|
+
else if (name === 'assignee' && value !== '') assignee = named(value);
|
|
140
|
+
else if (name === 'author' && value !== '') author = value;
|
|
141
|
+
else if (name === 'no' && value === 'milestone') milestone = { kind: 'none' };
|
|
142
|
+
else if (name === 'no' && value === 'assignee') assignee = { kind: 'none' };
|
|
143
|
+
else if (name === 'sort' && value === 'created-asc') order = 'oldest';
|
|
144
|
+
else if (name === 'sort' && value === 'created-desc') order = 'newest';
|
|
145
|
+
else if (name === undefined) words.push(written);
|
|
146
|
+
else unfiltered.push(written);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return { state, labels, milestone, assignee, author, order, words, unfiltered };
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** `value` as a qualifier's: quoted, with its quotes and backslashes escaped, when it holds a space or a quote. */
|
|
153
|
+
export const valueOf = (value: string) =>
|
|
154
|
+
/[\s"]/.test(value) ? `"${value.replaceAll(/["\\]/g, '\\$&')}"` : value;
|
|
155
|
+
|
|
156
|
+
/** The qualifiers an issue's or a pull request's box shares, for `filter`'s labels, people and order, each value as `quote` writes it. */
|
|
157
|
+
export const qualifiersOf = (
|
|
158
|
+
filter: Omit<IssueFilter, 'state' | 'words' | 'unfiltered'>,
|
|
159
|
+
quote: (value: string) => string = valueOf,
|
|
160
|
+
) => {
|
|
161
|
+
const terms: string[] = [];
|
|
162
|
+
|
|
163
|
+
for (const label of filter.labels) terms.push(`label:${quote(label)}`);
|
|
164
|
+
|
|
165
|
+
const { milestone, assignee } = filter;
|
|
166
|
+
if (milestone?.kind === 'named') terms.push(`milestone:${quote(milestone.name)}`);
|
|
167
|
+
|
|
168
|
+
if (milestone?.kind === 'none') terms.push('no:milestone');
|
|
169
|
+
|
|
170
|
+
if (assignee?.kind === 'named') terms.push(`assignee:${quote(assignee.name)}`);
|
|
171
|
+
|
|
172
|
+
if (assignee?.kind === 'none') terms.push('no:assignee');
|
|
173
|
+
|
|
174
|
+
if (filter.author !== undefined) terms.push(`author:${quote(filter.author)}`);
|
|
175
|
+
|
|
176
|
+
if (filter.order === 'oldest') terms.push('sort:created-asc');
|
|
177
|
+
|
|
178
|
+
return terms;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* The terms `filter` keeps as written, its qualifiers no filter takes and its words, with any whose
|
|
183
|
+
* quote is never closed last: it runs to the end of the text, so any term after it would join it.
|
|
184
|
+
*/
|
|
185
|
+
export const keptOf = (filter: Pick<IssueFilter, 'words' | 'unfiltered'>) => {
|
|
186
|
+
const kept = [...filter.unfiltered, ...filter.words];
|
|
187
|
+
const isOpen = (written: string) => termsOf(written)[0]?.open === true;
|
|
188
|
+
|
|
189
|
+
return [...kept.filter((written) => !isOpen(written)), ...kept.filter(isOpen)];
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
/** The box's text for `filter`: the query `filterOf` reads back as the same filter. */
|
|
193
|
+
export const queryOf = (filter: IssueFilter) => {
|
|
194
|
+
const state = filter.state === 'all' ? [] : [`is:${filter.state}`];
|
|
195
|
+
|
|
196
|
+
return ['is:issue', ...state, ...qualifiersOf(filter), ...keptOf(filter)].join(' ');
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/** The names `filter` holds, which a search query writes as values. */
|
|
200
|
+
const namesOf = (filter: Omit<IssueFilter, 'state' | 'words' | 'unfiltered'>) => {
|
|
201
|
+
const { labels, milestone, assignee, author } = filter;
|
|
202
|
+
const names = [...labels];
|
|
203
|
+
if (milestone?.kind === 'named') names.push(milestone.name);
|
|
204
|
+
|
|
205
|
+
if (assignee?.kind === 'named') names.push(assignee.name);
|
|
206
|
+
|
|
207
|
+
if (author !== undefined) names.push(author);
|
|
208
|
+
|
|
209
|
+
return names;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/** A value as search reads it: quoted when it holds a space. Search reads no escape. */
|
|
213
|
+
const searchValueOf = (value: string) => (/\s/.test(value) ? `"${value}"` : value);
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* The drop-in's search query for `filter` in `place`'s repo, its `kind` and state first, as
|
|
217
|
+
* `GET /search/issues` takes it, or `undefined` when a name holds a quote, which search's text
|
|
218
|
+
* can't write. `terms` are the kind's own qualifiers, such as a pull request's `draft:true`.
|
|
219
|
+
*/
|
|
220
|
+
export const searchQueryOf = (
|
|
221
|
+
place: RepoPlace,
|
|
222
|
+
filter: IssueFilter,
|
|
223
|
+
kind: 'issue' | 'pr' = 'issue',
|
|
224
|
+
terms: readonly string[] = [],
|
|
225
|
+
) => {
|
|
226
|
+
if (namesOf(filter).some((name) => name.includes('"'))) return undefined;
|
|
227
|
+
|
|
228
|
+
const state = filter.state === 'all' ? [] : [`is:${filter.state}`];
|
|
229
|
+
|
|
230
|
+
return [
|
|
231
|
+
`repo:${place.owner}/${place.repo}`,
|
|
232
|
+
`is:${kind}`,
|
|
233
|
+
...state,
|
|
234
|
+
...terms,
|
|
235
|
+
...qualifiersOf(filter, searchValueOf),
|
|
236
|
+
...filter.words,
|
|
237
|
+
].join(' ');
|
|
238
|
+
};
|