@dxos/plugin-github 0.7.4 → 0.14.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/LICENSE +102 -5
- package/PLUGIN.mdl +784 -0
- package/dist/lib/GitHubCapabilities.mjs +10 -0
- package/dist/lib/GitHubCapabilities.mjs.map +1 -0
- package/dist/lib/GitHubEvents.mjs +15 -0
- package/dist/lib/GitHubEvents.mjs.map +1 -0
- package/dist/lib/GitHubOperation.mjs +384 -0
- package/dist/lib/GitHubOperation.mjs.map +1 -0
- package/dist/lib/GitHubPlugin.mjs +16 -0
- package/dist/lib/GitHubPlugin.mjs.map +1 -0
- package/dist/lib/Walkthrough.mjs +59 -0
- package/dist/lib/Walkthrough.mjs.map +1 -0
- package/dist/lib/capabilities.browser.mjs +54 -0
- package/dist/lib/capabilities.browser.mjs.map +1 -0
- package/dist/lib/capabilities.mjs +54 -0
- package/dist/lib/capabilities.mjs.map +1 -0
- package/dist/lib/capabilities.node.mjs +30 -0
- package/dist/lib/capabilities.node.mjs.map +1 -0
- package/dist/lib/capabilities.tauri.mjs +54 -0
- package/dist/lib/capabilities.tauri.mjs.map +1 -0
- package/dist/lib/capabilities.workerd.mjs +30 -0
- package/dist/lib/capabilities.workerd.mjs.map +1 -0
- package/dist/lib/chunk-ImportPullRequestDialog.mjs +116 -0
- package/dist/lib/chunk-ImportPullRequestDialog.mjs.map +1 -0
- package/dist/lib/chunk-PLUGIN.mjs +6 -0
- package/dist/lib/chunk-PLUGIN.mjs.map +1 -0
- package/dist/lib/chunk-PullRequestArticle.mjs +1506 -0
- package/dist/lib/chunk-PullRequestArticle.mjs.map +1 -0
- package/dist/lib/chunk-PullRequestArticle2.mjs +2 -0
- package/dist/lib/chunk-PullRequestCardMenu.mjs +123 -0
- package/dist/lib/chunk-PullRequestCardMenu.mjs.map +1 -0
- package/dist/lib/chunk-PullRequestsArticle.mjs +594 -0
- package/dist/lib/chunk-PullRequestsArticle.mjs.map +1 -0
- package/dist/lib/chunk-WalkthroughArticle.mjs +26 -0
- package/dist/lib/chunk-WalkthroughArticle.mjs.map +1 -0
- package/dist/lib/chunk-add-pull-request-comment.mjs +19 -0
- package/dist/lib/chunk-add-pull-request-comment.mjs.map +1 -0
- package/dist/lib/chunk-add-pull-request-review-comment.mjs +25 -0
- package/dist/lib/chunk-add-pull-request-review-comment.mjs.map +1 -0
- package/dist/lib/chunk-app-graph-builder.mjs +39 -0
- package/dist/lib/chunk-app-graph-builder.mjs.map +1 -0
- package/dist/lib/chunk-connector.mjs +70 -0
- package/dist/lib/chunk-connector.mjs.map +1 -0
- package/dist/lib/chunk-constants.mjs +11 -0
- package/dist/lib/chunk-constants.mjs.map +1 -0
- package/dist/lib/chunk-errors.mjs +29 -0
- package/dist/lib/chunk-errors.mjs.map +1 -0
- package/dist/lib/chunk-generate-walkthrough.mjs +86 -0
- package/dist/lib/chunk-generate-walkthrough.mjs.map +1 -0
- package/dist/lib/chunk-generate.mjs +719 -0
- package/dist/lib/chunk-generate.mjs.map +1 -0
- package/dist/lib/chunk-get-pull-request-diff.mjs +25 -0
- package/dist/lib/chunk-get-pull-request-diff.mjs.map +1 -0
- package/dist/lib/chunk-get-pull-request-status.mjs +29 -0
- package/dist/lib/chunk-get-pull-request-status.mjs.map +1 -0
- package/dist/lib/chunk-get-repositories.mjs +32 -0
- package/dist/lib/chunk-get-repositories.mjs.map +1 -0
- package/dist/lib/chunk-github-api.mjs +375 -0
- package/dist/lib/chunk-github-api.mjs.map +1 -0
- package/dist/lib/chunk-github-link.mjs +59 -0
- package/dist/lib/chunk-github-link.mjs.map +1 -0
- package/dist/lib/chunk-import-pull-request-from-snapshot.mjs +25 -0
- package/dist/lib/chunk-import-pull-request-from-snapshot.mjs.map +1 -0
- package/dist/lib/chunk-import-pull-request.mjs +171 -0
- package/dist/lib/chunk-import-pull-request.mjs.map +1 -0
- package/dist/lib/chunk-link-resolver.mjs +109 -0
- package/dist/lib/chunk-link-resolver.mjs.map +1 -0
- package/dist/lib/chunk-markdown-extension.mjs +92 -0
- package/dist/lib/chunk-markdown-extension.mjs.map +1 -0
- package/dist/lib/chunk-materialize-target.mjs +36 -0
- package/dist/lib/chunk-materialize-target.mjs.map +1 -0
- package/dist/lib/chunk-operation-handler.mjs +12 -0
- package/dist/lib/chunk-operation-handler.mjs.map +1 -0
- package/dist/lib/chunk-page-action.mjs +22 -0
- package/dist/lib/chunk-page-action.mjs.map +1 -0
- package/dist/lib/chunk-pull-request.mjs +58 -0
- package/dist/lib/chunk-pull-request.mjs.map +1 -0
- package/dist/lib/chunk-pull-request2.mjs +110 -0
- package/dist/lib/chunk-pull-request2.mjs.map +1 -0
- package/dist/lib/chunk-react-surface.mjs +233 -0
- package/dist/lib/chunk-react-surface.mjs.map +1 -0
- package/dist/lib/chunk-refresh-pull-requests.mjs +49 -0
- package/dist/lib/chunk-refresh-pull-requests.mjs.map +1 -0
- package/dist/lib/chunk-rolldown-runtime.mjs +13 -0
- package/dist/lib/chunk-schema.mjs +15 -0
- package/dist/lib/chunk-schema.mjs.map +1 -0
- package/dist/lib/chunk-skill-definition.mjs +10 -0
- package/dist/lib/chunk-skill-definition.mjs.map +1 -0
- package/dist/lib/chunk-submit-pull-request-approval.mjs +56 -0
- package/dist/lib/chunk-submit-pull-request-approval.mjs.map +1 -0
- package/dist/lib/chunk-sync-pull-request.mjs +26 -0
- package/dist/lib/chunk-sync-pull-request.mjs.map +1 -0
- package/dist/lib/chunk-sync.mjs +481 -0
- package/dist/lib/chunk-sync.mjs.map +1 -0
- package/dist/lib/chunk-useOpenObject.mjs +43 -0
- package/dist/lib/chunk-useOpenObject.mjs.map +1 -0
- package/dist/lib/extensions.mjs +132 -0
- package/dist/lib/extensions.mjs.map +1 -0
- package/dist/lib/index.mjs +4 -0
- package/dist/lib/meta.mjs +47 -0
- package/dist/lib/meta.mjs.map +1 -0
- package/dist/lib/ns/Extensions.mjs +18 -0
- package/dist/lib/ns/Extensions.mjs.map +1 -0
- package/dist/lib/operations.mjs +23 -0
- package/dist/lib/operations.mjs.map +1 -0
- package/dist/lib/plugin.mjs +9 -0
- package/dist/lib/plugin.mjs.map +1 -0
- package/dist/lib/skills.mjs +44 -0
- package/dist/lib/skills.mjs.map +1 -0
- package/dist/lib/testing.mjs +189 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/lib/translations.mjs +136 -0
- package/dist/lib/translations.mjs.map +1 -0
- package/dist/lib/types.mjs +5 -0
- package/dist/types/dx.config.d.ts +28 -0
- package/dist/types/dx.config.d.ts.map +1 -0
- package/dist/types/src/Extensions.d.ts +2 -0
- package/dist/types/src/Extensions.d.ts.map +1 -0
- package/dist/types/src/GitHubPlugin.d.ts +37 -0
- package/dist/types/src/GitHubPlugin.d.ts.map +1 -0
- package/dist/types/src/GitHubPlugin.workerd.test.d.ts +2 -0
- package/dist/types/src/GitHubPlugin.workerd.test.d.ts.map +1 -0
- package/dist/types/src/approval.d.ts +21 -0
- package/dist/types/src/approval.d.ts.map +1 -0
- package/dist/types/src/approval.test.d.ts +2 -0
- package/dist/types/src/approval.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +9 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/connector.d.ts +17 -0
- package/dist/types/src/capabilities/connector.d.ts.map +1 -0
- package/dist/types/src/capabilities/gen/browser.d.ts +13 -0
- package/dist/types/src/capabilities/gen/browser.d.ts.map +1 -0
- package/dist/types/src/capabilities/gen/node.d.ts +13 -0
- package/dist/types/src/capabilities/gen/node.d.ts.map +1 -0
- package/dist/types/src/capabilities/gen/tauri.d.ts +13 -0
- package/dist/types/src/capabilities/gen/tauri.d.ts.map +1 -0
- package/dist/types/src/capabilities/gen/workerd.d.ts +13 -0
- package/dist/types/src/capabilities/gen/workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +13 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/link-resolver.d.ts +10 -0
- package/dist/types/src/capabilities/link-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown-extension.d.ts +14 -0
- package/dist/types/src/capabilities/markdown-extension.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +5 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/page-action.d.ts +5 -0
- package/dist/types/src/capabilities/page-action.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/schema.d.ts +12 -0
- package/dist/types/src/capabilities/schema.d.ts.map +1 -0
- package/dist/types/src/capabilities/skill-definition.d.ts +5 -0
- package/dist/types/src/capabilities/skill-definition.d.ts.map +1 -0
- package/dist/types/src/cards/GitHubCard.d.ts +11 -0
- package/dist/types/src/cards/GitHubCard.d.ts.map +1 -0
- package/dist/types/src/cards/GitHubCard.stories.d.ts +45 -0
- package/dist/types/src/cards/GitHubCard.stories.d.ts.map +1 -0
- package/dist/types/src/cards/PullRequestCard.d.ts +9 -0
- package/dist/types/src/cards/PullRequestCard.d.ts.map +1 -0
- package/dist/types/src/cards/index.d.ts +3 -0
- package/dist/types/src/cards/index.d.ts.map +1 -0
- package/dist/types/src/components/CommentComposer/CommentComposer.d.ts +30 -0
- package/dist/types/src/components/CommentComposer/CommentComposer.d.ts.map +1 -0
- package/dist/types/src/components/CommentComposer/index.d.ts +2 -0
- package/dist/types/src/components/CommentComposer/index.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestFiles/DiffStat.d.ts +8 -0
- package/dist/types/src/components/PullRequestFiles/DiffStat.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestFiles/FileTree.d.ts +17 -0
- package/dist/types/src/components/PullRequestFiles/FileTree.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestFiles/PullRequestFiles.d.ts +23 -0
- package/dist/types/src/components/PullRequestFiles/PullRequestFiles.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestFiles/files.d.ts +39 -0
- package/dist/types/src/components/PullRequestFiles/files.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestFiles/files.test.d.ts +2 -0
- package/dist/types/src/components/PullRequestFiles/files.test.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestFiles/index.d.ts +5 -0
- package/dist/types/src/components/PullRequestFiles/index.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/ArtifactPill.d.ts +21 -0
- package/dist/types/src/components/PullRequestOverview/ArtifactPill.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/CheckRunList.d.ts +18 -0
- package/dist/types/src/components/PullRequestOverview/CheckRunList.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/CheckRunList.test.d.ts +2 -0
- package/dist/types/src/components/PullRequestOverview/CheckRunList.test.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/PullRequestDetails.d.ts +10 -0
- package/dist/types/src/components/PullRequestOverview/PullRequestDetails.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/PullRequestOverview.d.ts +16 -0
- package/dist/types/src/components/PullRequestOverview/PullRequestOverview.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/RelatedCards.d.ts +28 -0
- package/dist/types/src/components/PullRequestOverview/RelatedCards.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/index.d.ts +6 -0
- package/dist/types/src/components/PullRequestOverview/index.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestStatus/PullRequestStatus.d.ts +20 -0
- package/dist/types/src/components/PullRequestStatus/PullRequestStatus.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestStatus/index.d.ts +2 -0
- package/dist/types/src/components/PullRequestStatus/index.d.ts.map +1 -0
- package/dist/types/src/components/WalkthroughView/WalkthroughView.d.ts +18 -0
- package/dist/types/src/components/WalkthroughView/WalkthroughView.d.ts.map +1 -0
- package/dist/types/src/components/WalkthroughView/extensions.d.ts +16 -0
- package/dist/types/src/components/WalkthroughView/extensions.d.ts.map +1 -0
- package/dist/types/src/components/WalkthroughView/index.d.ts +3 -0
- package/dist/types/src/components/WalkthroughView/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +5 -8
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +7 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/containers/ImportPullRequestDialog/ImportPullRequestDialog.d.ts +6 -0
- package/dist/types/src/containers/ImportPullRequestDialog/ImportPullRequestDialog.d.ts.map +1 -0
- package/dist/types/src/containers/ImportPullRequestDialog/index.d.ts +3 -0
- package/dist/types/src/containers/ImportPullRequestDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestArticle/PullRequestArticle.d.ts +15 -0
- package/dist/types/src/containers/PullRequestArticle/PullRequestArticle.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestArticle/failure.d.ts +10 -0
- package/dist/types/src/containers/PullRequestArticle/failure.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestArticle/failure.test.d.ts +2 -0
- package/dist/types/src/containers/PullRequestArticle/failure.test.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestArticle/index.d.ts +2 -0
- package/dist/types/src/containers/PullRequestArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestCardMenu/PullRequestCardMenu.d.ts +14 -0
- package/dist/types/src/containers/PullRequestCardMenu/PullRequestCardMenu.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestCardMenu/index.d.ts +2 -0
- package/dist/types/src/containers/PullRequestCardMenu/index.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestsArticle/PullRequestsArticle.d.ts +13 -0
- package/dist/types/src/containers/PullRequestsArticle/PullRequestsArticle.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestsArticle/arrange.d.ts +44 -0
- package/dist/types/src/containers/PullRequestsArticle/arrange.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestsArticle/arrange.test.d.ts +2 -0
- package/dist/types/src/containers/PullRequestsArticle/arrange.test.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestsArticle/format.d.ts +3 -0
- package/dist/types/src/containers/PullRequestsArticle/format.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestsArticle/index.d.ts +2 -0
- package/dist/types/src/containers/PullRequestsArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/WalkthroughArticle/WalkthroughArticle.d.ts +13 -0
- package/dist/types/src/containers/WalkthroughArticle/WalkthroughArticle.d.ts.map +1 -0
- package/dist/types/src/containers/WalkthroughArticle/index.d.ts +2 -0
- package/dist/types/src/containers/WalkthroughArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +7 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/errors.d.ts +157 -0
- package/dist/types/src/errors.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +3 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/extensions/links.d.ts +21 -0
- package/dist/types/src/extensions/links.d.ts.map +1 -0
- package/dist/types/src/extensions/links.test.d.ts +2 -0
- package/dist/types/src/extensions/links.test.d.ts.map +1 -0
- package/dist/types/src/extensions/references.d.ts +23 -0
- package/dist/types/src/extensions/references.d.ts.map +1 -0
- package/dist/types/src/extensions/references.test.d.ts +2 -0
- package/dist/types/src/extensions/references.test.d.ts.map +1 -0
- package/dist/types/src/github-link.d.ts +29 -0
- package/dist/types/src/github-link.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +5 -2
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useOpenObject.d.ts +9 -0
- package/dist/types/src/hooks/useOpenObject.d.ts.map +1 -0
- package/dist/types/src/hooks/usePullRequestChecks.d.ts +10 -0
- package/dist/types/src/hooks/usePullRequestChecks.d.ts.map +1 -0
- package/dist/types/src/hooks/usePullRequestDiff.d.ts +12 -0
- package/dist/types/src/hooks/usePullRequestDiff.d.ts.map +1 -0
- package/dist/types/src/hooks/usePullRequestFiles.d.ts +22 -0
- package/dist/types/src/hooks/usePullRequestFiles.d.ts.map +1 -0
- package/dist/types/src/hooks/useSyncPullRequest.d.ts +10 -0
- package/dist/types/src/hooks/useSyncPullRequest.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +34 -11
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/add-pull-request-comment.d.ts +5 -0
- package/dist/types/src/operations/add-pull-request-comment.d.ts.map +1 -0
- package/dist/types/src/operations/add-pull-request-review-comment.d.ts +5 -0
- package/dist/types/src/operations/add-pull-request-review-comment.d.ts.map +1 -0
- package/dist/types/src/operations/generate-walkthrough.d.ts +11 -0
- package/dist/types/src/operations/generate-walkthrough.d.ts.map +1 -0
- package/dist/types/src/operations/get-pull-request-diff.d.ts +5 -0
- package/dist/types/src/operations/get-pull-request-diff.d.ts.map +1 -0
- package/dist/types/src/operations/get-pull-request-status.d.ts +5 -0
- package/dist/types/src/operations/get-pull-request-status.d.ts.map +1 -0
- package/dist/types/src/operations/get-repositories.d.ts +13 -0
- package/dist/types/src/operations/get-repositories.d.ts.map +1 -0
- package/dist/types/src/operations/import-pull-request-from-snapshot.d.ts +12 -0
- package/dist/types/src/operations/import-pull-request-from-snapshot.d.ts.map +1 -0
- package/dist/types/src/operations/import-pull-request.d.ts +63 -0
- package/dist/types/src/operations/import-pull-request.d.ts.map +1 -0
- package/dist/types/src/operations/import-pull-request.test.d.ts +2 -0
- package/dist/types/src/operations/import-pull-request.test.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/materialize-target.d.ts +12 -0
- package/dist/types/src/operations/materialize-target.d.ts.map +1 -0
- package/dist/types/src/operations/pull-request.d.ts +48 -0
- package/dist/types/src/operations/pull-request.d.ts.map +1 -0
- package/dist/types/src/operations/pull-request.test.d.ts +2 -0
- package/dist/types/src/operations/pull-request.test.d.ts.map +1 -0
- package/dist/types/src/operations/refresh-pull-requests.d.ts +5 -0
- package/dist/types/src/operations/refresh-pull-requests.d.ts.map +1 -0
- package/dist/types/src/operations/refresh.d.ts +37 -0
- package/dist/types/src/operations/refresh.d.ts.map +1 -0
- package/dist/types/src/operations/refresh.test.d.ts +2 -0
- package/dist/types/src/operations/refresh.test.d.ts.map +1 -0
- package/dist/types/src/operations/submit-pull-request-approval.d.ts +5 -0
- package/dist/types/src/operations/submit-pull-request-approval.d.ts.map +1 -0
- package/dist/types/src/operations/sync-pull-request.d.ts +5 -0
- package/dist/types/src/operations/sync-pull-request.d.ts.map +1 -0
- package/dist/types/src/operations/sync.d.ts +123 -0
- package/dist/types/src/operations/sync.d.ts.map +1 -0
- package/dist/types/src/operations/sync.test.d.ts +2 -0
- package/dist/types/src/operations/sync.test.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/plugin.test.d.ts +2 -0
- package/dist/types/src/plugin.test.d.ts.map +1 -0
- package/dist/types/src/pull-request-body.d.ts +37 -0
- package/dist/types/src/pull-request-body.d.ts.map +1 -0
- package/dist/types/src/pull-request-body.test.d.ts +2 -0
- package/dist/types/src/pull-request-body.test.d.ts.map +1 -0
- package/dist/types/src/pull-request.d.ts +28 -0
- package/dist/types/src/pull-request.d.ts.map +1 -0
- package/dist/types/src/pull-request.test.d.ts +2 -0
- package/dist/types/src/pull-request.test.d.ts.map +1 -0
- package/dist/types/src/services/github-api.d.ts +332 -0
- package/dist/types/src/services/github-api.d.ts.map +1 -0
- package/dist/types/src/services/index.d.ts +2 -0
- package/dist/types/src/services/index.d.ts.map +1 -0
- package/dist/types/src/skills/GitHubSkill.d.ts +12 -0
- package/dist/types/src/skills/GitHubSkill.d.ts.map +1 -0
- package/dist/types/src/skills/index.d.ts +2 -0
- package/dist/types/src/skills/index.d.ts.map +1 -0
- package/dist/types/src/stories/Generate.stories.d.ts +27 -0
- package/dist/types/src/stories/Generate.stories.d.ts.map +1 -0
- package/dist/types/src/stories/Links.stories.d.ts +23 -0
- package/dist/types/src/stories/Links.stories.d.ts.map +1 -0
- package/dist/types/src/stories/PullRequestArticle.stories.d.ts +359 -0
- package/dist/types/src/stories/PullRequestArticle.stories.d.ts.map +1 -0
- package/dist/types/src/stories/PullRequestFiles.stories.d.ts +365 -0
- package/dist/types/src/stories/PullRequestFiles.stories.d.ts.map +1 -0
- package/dist/types/src/stories/PullRequestOverview.stories.d.ts +367 -0
- package/dist/types/src/stories/PullRequestOverview.stories.d.ts.map +1 -0
- package/dist/types/src/stories/PullRequestsArticle.stories.d.ts +357 -0
- package/dist/types/src/stories/PullRequestsArticle.stories.d.ts.map +1 -0
- package/dist/types/src/stories/Walkthrough.stories.d.ts +380 -0
- package/dist/types/src/stories/Walkthrough.stories.d.ts.map +1 -0
- package/dist/types/src/stories/github.d.ts +23 -0
- package/dist/types/src/stories/github.d.ts.map +1 -0
- package/dist/types/src/stories/github.test.d.ts +2 -0
- package/dist/types/src/stories/github.test.d.ts.map +1 -0
- package/dist/types/src/stories/walkthrough-fixture.d.ts +8 -0
- package/dist/types/src/stories/walkthrough-fixture.d.ts.map +1 -0
- package/dist/types/src/testing/fixtures.d.ts +14 -0
- package/dist/types/src/testing/fixtures.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +4 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/plugin.d.ts +4 -0
- package/dist/types/src/testing/plugin.d.ts.map +1 -0
- package/dist/types/src/testing/pull-request-13348.d.ts +6 -0
- package/dist/types/src/testing/pull-request-13348.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +339 -53
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/GitHubCapabilities.d.ts +13 -0
- package/dist/types/src/types/GitHubCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/GitHubEvents.d.ts +8 -0
- package/dist/types/src/types/GitHubEvents.d.ts.map +1 -0
- package/dist/types/src/types/GitHubOperation.d.ts +281 -0
- package/dist/types/src/types/GitHubOperation.d.ts.map +1 -0
- package/dist/types/src/types/PullRequestsView.d.ts +35 -0
- package/dist/types/src/types/PullRequestsView.d.ts.map +1 -0
- package/dist/types/src/types/Walkthrough.d.ts +31 -0
- package/dist/types/src/types/Walkthrough.d.ts.map +1 -0
- package/dist/types/src/types/Walkthrough.test.d.ts +2 -0
- package/dist/types/src/types/Walkthrough.test.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +5 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/walkthrough/fill.d.ts +28 -0
- package/dist/types/src/walkthrough/fill.d.ts.map +1 -0
- package/dist/types/src/walkthrough/fill.test.d.ts +2 -0
- package/dist/types/src/walkthrough/fill.test.d.ts.map +1 -0
- package/dist/types/src/walkthrough/generate.d.ts +67 -0
- package/dist/types/src/walkthrough/generate.d.ts.map +1 -0
- package/dist/types/src/walkthrough/generate.test.d.ts +2 -0
- package/dist/types/src/walkthrough/generate.test.d.ts.map +1 -0
- package/dist/types/src/walkthrough/generated.d.ts +20 -0
- package/dist/types/src/walkthrough/generated.d.ts.map +1 -0
- package/dist/types/src/walkthrough/generated.test.d.ts +2 -0
- package/dist/types/src/walkthrough/generated.test.d.ts.map +1 -0
- package/dist/types/src/walkthrough/headings.d.ts +8 -0
- package/dist/types/src/walkthrough/headings.d.ts.map +1 -0
- package/dist/types/src/walkthrough/headings.test.d.ts +2 -0
- package/dist/types/src/walkthrough/headings.test.d.ts.map +1 -0
- package/dist/types/src/walkthrough/index.d.ts +9 -0
- package/dist/types/src/walkthrough/index.d.ts.map +1 -0
- package/dist/types/src/walkthrough/patch.d.ts +48 -0
- package/dist/types/src/walkthrough/patch.d.ts.map +1 -0
- package/dist/types/src/walkthrough/plan.d.ts +55 -0
- package/dist/types/src/walkthrough/plan.d.ts.map +1 -0
- package/dist/types/src/walkthrough/plan.test.d.ts +2 -0
- package/dist/types/src/walkthrough/plan.test.d.ts.map +1 -0
- package/dist/types/src/walkthrough/prompt.d.ts +33 -0
- package/dist/types/src/walkthrough/prompt.d.ts.map +1 -0
- package/dist/types/src/walkthrough/prompt.test.d.ts +2 -0
- package/dist/types/src/walkthrough/prompt.test.d.ts.map +1 -0
- package/dist/types/src/walkthrough/score.d.ts +43 -0
- package/dist/types/src/walkthrough/score.d.ts.map +1 -0
- package/dist/types/src/walkthrough/score.test.d.ts +2 -0
- package/dist/types/src/walkthrough/score.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dx.config.ts +39 -0
- package/package.json +167 -48
- package/src/Extensions.ts +7 -0
- package/src/GitHubPlugin.ts +15 -0
- package/src/GitHubPlugin.workerd.test.ts +23 -0
- package/src/approval.test.ts +40 -0
- package/src/approval.ts +39 -0
- package/src/capabilities/app-graph-builder.ts +47 -0
- package/src/capabilities/connector.ts +95 -0
- package/src/capabilities/gen/browser.ts +82 -0
- package/src/capabilities/gen/node.ts +43 -0
- package/src/capabilities/gen/tauri.ts +82 -0
- package/src/capabilities/gen/workerd.ts +43 -0
- package/src/capabilities/index.ts +71 -0
- package/src/capabilities/link-resolver.ts +137 -0
- package/src/capabilities/markdown-extension.ts +146 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/page-action.ts +32 -0
- package/src/capabilities/react-surface.ts +98 -0
- package/src/capabilities/schema.ts +16 -0
- package/src/capabilities/skill-definition.ts +14 -0
- package/src/cards/GitHubCard.stories.tsx +165 -0
- package/src/cards/GitHubCard.tsx +93 -0
- package/src/cards/PullRequestCard.tsx +23 -0
- package/src/cards/index.ts +6 -0
- package/src/components/CommentComposer/CommentComposer.tsx +109 -0
- package/src/components/CommentComposer/index.ts +5 -0
- package/src/components/PullRequestFiles/DiffStat.tsx +15 -0
- package/src/components/PullRequestFiles/FileTree.tsx +102 -0
- package/src/components/PullRequestFiles/PullRequestFiles.tsx +87 -0
- package/src/components/PullRequestFiles/files.test.ts +59 -0
- package/src/components/PullRequestFiles/files.ts +115 -0
- package/src/components/PullRequestFiles/index.ts +8 -0
- package/src/components/PullRequestOverview/ArtifactPill.tsx +82 -0
- package/src/components/PullRequestOverview/CheckRunList.test.ts +29 -0
- package/src/components/PullRequestOverview/CheckRunList.tsx +141 -0
- package/src/components/PullRequestOverview/PullRequestDetails.tsx +15 -0
- package/src/components/PullRequestOverview/PullRequestOverview.tsx +110 -0
- package/src/components/PullRequestOverview/RelatedCards.tsx +147 -0
- package/src/components/PullRequestOverview/index.ts +9 -0
- package/src/components/PullRequestStatus/PullRequestStatus.tsx +84 -0
- package/src/components/PullRequestStatus/index.ts +5 -0
- package/src/components/WalkthroughView/WalkthroughView.tsx +62 -0
- package/src/components/WalkthroughView/extensions.ts +53 -0
- package/src/components/WalkthroughView/index.ts +6 -0
- package/src/components/index.ts +6 -9
- package/src/constants.ts +12 -0
- package/src/containers/ImportPullRequestDialog/ImportPullRequestDialog.tsx +160 -0
- package/src/containers/ImportPullRequestDialog/index.ts +7 -0
- package/src/containers/PullRequestArticle/PullRequestArticle.tsx +573 -0
- package/src/containers/PullRequestArticle/failure.test.ts +42 -0
- package/src/containers/PullRequestArticle/failure.ts +16 -0
- package/src/containers/PullRequestArticle/index.ts +5 -0
- package/src/containers/PullRequestCardMenu/PullRequestCardMenu.tsx +134 -0
- package/src/containers/PullRequestCardMenu/index.ts +5 -0
- package/src/containers/PullRequestsArticle/PullRequestsArticle.tsx +361 -0
- package/src/containers/PullRequestsArticle/arrange.test.ts +122 -0
- package/src/containers/PullRequestsArticle/arrange.ts +245 -0
- package/src/containers/PullRequestsArticle/format.ts +31 -0
- package/src/containers/PullRequestsArticle/index.ts +5 -0
- package/src/containers/WalkthroughArticle/WalkthroughArticle.tsx +31 -0
- package/src/containers/WalkthroughArticle/index.ts +5 -0
- package/src/containers/index.ts +11 -0
- package/src/errors.ts +61 -0
- package/src/extensions/index.ts +6 -0
- package/src/extensions/links.test.ts +133 -0
- package/src/extensions/links.ts +91 -0
- package/src/extensions/references.test.ts +83 -0
- package/src/extensions/references.ts +100 -0
- package/src/github-link.ts +70 -0
- package/src/hooks/index.ts +6 -3
- package/src/hooks/useOpenObject.ts +48 -0
- package/src/hooks/usePullRequestChecks.ts +81 -0
- package/src/hooks/usePullRequestDiff.ts +57 -0
- package/src/hooks/usePullRequestFiles.ts +98 -0
- package/src/hooks/useSyncPullRequest.ts +51 -0
- package/src/index.ts +4 -6
- package/src/meta.ts +8 -13
- package/src/operations/add-pull-request-comment.ts +31 -0
- package/src/operations/add-pull-request-review-comment.ts +32 -0
- package/src/operations/generate-walkthrough.ts +124 -0
- package/src/operations/get-pull-request-diff.ts +37 -0
- package/src/operations/get-pull-request-status.ts +44 -0
- package/src/operations/get-repositories.ts +53 -0
- package/src/operations/import-pull-request-from-snapshot.ts +48 -0
- package/src/operations/import-pull-request.test.ts +151 -0
- package/src/operations/import-pull-request.ts +149 -0
- package/src/operations/index.ts +30 -0
- package/src/operations/materialize-target.ts +60 -0
- package/src/operations/pull-request.test.ts +120 -0
- package/src/operations/pull-request.ts +141 -0
- package/src/operations/refresh-pull-requests.ts +69 -0
- package/src/operations/refresh.test.ts +112 -0
- package/src/operations/refresh.ts +111 -0
- package/src/operations/submit-pull-request-approval.ts +41 -0
- package/src/operations/sync-pull-request.ts +34 -0
- package/src/operations/sync.test.ts +453 -0
- package/src/operations/sync.ts +807 -0
- package/src/plugin.test.ts +40 -0
- package/src/plugin.ts +37 -0
- package/src/pull-request-body.test.ts +61 -0
- package/src/pull-request-body.ts +144 -0
- package/src/pull-request.test.ts +67 -0
- package/src/pull-request.ts +80 -0
- package/src/services/github-api.ts +735 -0
- package/src/services/index.ts +5 -0
- package/src/skills/GitHubSkill.ts +46 -0
- package/src/skills/index.ts +5 -0
- package/src/stories/Generate.stories.tsx +152 -0
- package/src/stories/Links.stories.tsx +153 -0
- package/src/stories/PullRequestArticle.stories.tsx +107 -0
- package/src/stories/PullRequestFiles.stories.tsx +69 -0
- package/src/stories/PullRequestOverview.stories.tsx +114 -0
- package/src/stories/PullRequestsArticle.stories.tsx +170 -0
- package/src/stories/Walkthrough.stories.tsx +110 -0
- package/src/stories/github.test.ts +65 -0
- package/src/stories/github.ts +70 -0
- package/src/stories/walkthrough-fixture.ts +115 -0
- package/src/testing/fixtures.ts +99 -0
- package/src/testing/index.ts +7 -0
- package/src/testing/plugin.ts +25 -0
- package/src/testing/pull-request-13348.ts +104 -0
- package/src/testing/pull-request-13363.patch +2981 -0
- package/src/translations.ts +135 -63
- package/src/types/GitHubCapabilities.ts +27 -0
- package/src/types/GitHubEvents.ts +16 -0
- package/src/types/GitHubOperation.ts +397 -0
- package/src/types/PullRequestsView.ts +45 -0
- package/src/types/Walkthrough.test.ts +75 -0
- package/src/types/Walkthrough.ts +66 -0
- package/src/types/index.ts +8 -0
- package/src/vite-env.d.ts +15 -0
- package/src/walkthrough/fill.test.ts +337 -0
- package/src/walkthrough/fill.ts +246 -0
- package/src/walkthrough/generate.test.ts +219 -0
- package/src/walkthrough/generate.ts +248 -0
- package/src/walkthrough/generated.test.ts +70 -0
- package/src/walkthrough/generated.ts +70 -0
- package/src/walkthrough/headings.test.ts +40 -0
- package/src/walkthrough/headings.ts +39 -0
- package/src/walkthrough/index.ts +12 -0
- package/src/walkthrough/patch.ts +154 -0
- package/src/walkthrough/plan.test.ts +178 -0
- package/src/walkthrough/plan.ts +251 -0
- package/src/walkthrough/prompt.test.ts +100 -0
- package/src/walkthrough/prompt.ts +147 -0
- package/src/walkthrough/score.test.ts +272 -0
- package/src/walkthrough/score.ts +430 -0
- package/README.md +0 -15
- package/dist/lib/browser/chunk-S4MPSBA5.mjs +0 -21
- package/dist/lib/browser/chunk-S4MPSBA5.mjs.map +0 -7
- package/dist/lib/browser/index.css +0 -7
- package/dist/lib/browser/index.css.map +0 -7
- package/dist/lib/browser/index.mjs +0 -1535
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/meta.mjs +0 -11
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/types/src/GithubPlugin.d.ts +0 -4
- package/dist/types/src/GithubPlugin.d.ts.map +0 -1
- package/dist/types/src/components/EmbeddedMain/EmbeddedMain.d.ts +0 -4
- package/dist/types/src/components/EmbeddedMain/EmbeddedMain.d.ts.map +0 -1
- package/dist/types/src/components/EmbeddedMain/GfmPreview.d.ts +0 -9
- package/dist/types/src/components/EmbeddedMain/GfmPreview.d.ts.map +0 -1
- package/dist/types/src/components/EmbeddedMain/index.d.ts +0 -2
- package/dist/types/src/components/EmbeddedMain/index.d.ts.map +0 -1
- package/dist/types/src/components/ExportDialog.d.ts +0 -8
- package/dist/types/src/components/ExportDialog.d.ts.map +0 -1
- package/dist/types/src/components/GithubApiProviders/GitHubSettings.d.ts +0 -3
- package/dist/types/src/components/GithubApiProviders/GitHubSettings.d.ts.map +0 -1
- package/dist/types/src/components/GithubApiProviders/OctokitProvider.d.ts +0 -15
- package/dist/types/src/components/GithubApiProviders/OctokitProvider.d.ts.map +0 -1
- package/dist/types/src/components/GithubApiProviders/index.d.ts +0 -3
- package/dist/types/src/components/GithubApiProviders/index.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/DocumentTreeItem.d.ts +0 -6
- package/dist/types/src/components/GithubEchoResolverProviders/DocumentTreeItem.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverContext.d.ts +0 -7
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverContext.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverDialog.d.ts +0 -6
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverDialog.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverProps.d.ts +0 -16
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverProps.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverTree.d.ts +0 -3
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverTree.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/SpacePickerTreeItem.d.ts +0 -11
- package/dist/types/src/components/GithubEchoResolverProviders/SpacePickerTreeItem.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/index.d.ts +0 -3
- package/dist/types/src/components/GithubEchoResolverProviders/index.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/spaceResolvers.d.ts +0 -6
- package/dist/types/src/components/GithubEchoResolverProviders/spaceResolvers.d.ts.map +0 -1
- package/dist/types/src/components/ImportDialog.d.ts +0 -7
- package/dist/types/src/components/ImportDialog.d.ts.map +0 -1
- package/dist/types/src/components/Issue.d.ts +0 -5
- package/dist/types/src/components/Issue.d.ts.map +0 -1
- package/dist/types/src/components/Loading/Loading.d.ts +0 -15
- package/dist/types/src/components/Loading/Loading.d.ts.map +0 -1
- package/dist/types/src/components/Loading/Loading.stories.d.ts +0 -40
- package/dist/types/src/components/Loading/Loading.stories.d.ts.map +0 -1
- package/dist/types/src/components/Loading/index.d.ts +0 -2
- package/dist/types/src/components/Loading/index.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownActions.d.ts +0 -7
- package/dist/types/src/components/MarkdownActions.d.ts.map +0 -1
- package/dist/types/src/components/UrlDialog.d.ts +0 -6
- package/dist/types/src/components/UrlDialog.d.ts.map +0 -1
- package/dist/types/src/hooks/useDocGhId.d.ts +0 -6
- package/dist/types/src/hooks/useDocGhId.d.ts.map +0 -1
- package/dist/types/src/hooks/useGhIdFromUrl.d.ts +0 -2
- package/dist/types/src/hooks/useGhIdFromUrl.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -30
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/GithubPlugin.tsx +0 -127
- package/src/components/EmbeddedMain/EmbeddedMain.tsx +0 -294
- package/src/components/EmbeddedMain/GfmPreview.tsx +0 -110
- package/src/components/EmbeddedMain/embedded.css +0 -3
- package/src/components/EmbeddedMain/index.ts +0 -5
- package/src/components/ExportDialog.tsx +0 -157
- package/src/components/GithubApiProviders/GitHubSettings.tsx +0 -72
- package/src/components/GithubApiProviders/OctokitProvider.tsx +0 -60
- package/src/components/GithubApiProviders/index.ts +0 -6
- package/src/components/GithubEchoResolverProviders/DocumentTreeItem.tsx +0 -26
- package/src/components/GithubEchoResolverProviders/ResolverContext.tsx +0 -137
- package/src/components/GithubEchoResolverProviders/ResolverDialog.tsx +0 -34
- package/src/components/GithubEchoResolverProviders/ResolverProps.ts +0 -23
- package/src/components/GithubEchoResolverProviders/ResolverTree.tsx +0 -86
- package/src/components/GithubEchoResolverProviders/SpacePickerTreeItem.tsx +0 -105
- package/src/components/GithubEchoResolverProviders/index.ts +0 -6
- package/src/components/GithubEchoResolverProviders/spaceResolvers.ts +0 -86
- package/src/components/ImportDialog.tsx +0 -72
- package/src/components/Issue.tsx +0 -62
- package/src/components/Loading/Loading.stories.tsx +0 -32
- package/src/components/Loading/Loading.tsx +0 -70
- package/src/components/Loading/index.ts +0 -5
- package/src/components/MarkdownActions.tsx +0 -136
- package/src/components/UrlDialog.tsx +0 -52
- package/src/hooks/useDocGhId.ts +0 -38
- package/src/hooks/useGhIdFromUrl.ts +0 -26
- package/src/types.ts +0 -51
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Filter } from '@dxos/echo';
|
|
6
|
+
import { matchesFilter } from '@dxos/echo-query';
|
|
7
|
+
import { PullRequest, type Task } from '@dxos/types';
|
|
8
|
+
|
|
9
|
+
import { type GitHubOperation } from '#types';
|
|
10
|
+
|
|
11
|
+
import type * as PullRequestsView from '../../types/PullRequestsView.ts';
|
|
12
|
+
|
|
13
|
+
/** The live part of a pull request's standing, read from GitHub rather than stored. */
|
|
14
|
+
export type PullRequestChecks = {
|
|
15
|
+
ci: GitHubOperation.CiState;
|
|
16
|
+
checks: GitHubOperation.CheckCounts;
|
|
17
|
+
review: GitHubOperation.ReviewState;
|
|
18
|
+
approvals: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** One row of the list: the stored pull request, its live checks once they arrive, and the tasks that list it. */
|
|
22
|
+
export type PullRequestRow = {
|
|
23
|
+
pullRequest: PullRequest.PullRequest;
|
|
24
|
+
checks?: PullRequestChecks;
|
|
25
|
+
tasks: readonly Task.Task[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type PullRequestRowGroup = {
|
|
29
|
+
id: string;
|
|
30
|
+
/** A literal (a repository, an author) or a translation key in the plugin's namespace. */
|
|
31
|
+
label: string;
|
|
32
|
+
translate?: boolean;
|
|
33
|
+
icon: string;
|
|
34
|
+
hue?: string;
|
|
35
|
+
rows: readonly PullRequestRow[];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** What a free-text term searches: what a reader sees in the row. */
|
|
39
|
+
const rowText = (pullRequest: PullRequest.PullRequest) => [
|
|
40
|
+
pullRequest.title,
|
|
41
|
+
PullRequest.reference(pullRequest),
|
|
42
|
+
pullRequest.author,
|
|
43
|
+
pullRequest.headBranch,
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
/** The rows the toolbar's query keeps, in input order; an absent filter keeps every row. */
|
|
47
|
+
export const filterRows = (rows: readonly PullRequestRow[], filter?: Filter.Any): readonly PullRequestRow[] =>
|
|
48
|
+
filter ? rows.filter(({ pullRequest }) => matchesFilter(filter, pullRequest, { text: rowText })) : rows;
|
|
49
|
+
|
|
50
|
+
const STATE_WEIGHT: Record<PullRequest.State, number> = { open: 1_000, draft: 600, merged: 100, closed: 0 };
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* How much a row asks of the reader now: an open pull request outranks a draft, which outranks a
|
|
54
|
+
* finished one; within those, red CI or requested changes (something to fix) outrank one ready to
|
|
55
|
+
* merge, which outranks one still waiting; and a pull request some task tracks is nudged up.
|
|
56
|
+
*/
|
|
57
|
+
export const relevance = ({ pullRequest, checks, tasks }: PullRequestRow): number => {
|
|
58
|
+
let score = STATE_WEIGHT[pullRequest.state];
|
|
59
|
+
if (pullRequest.state === 'open' || pullRequest.state === 'draft') {
|
|
60
|
+
if (checks?.ci === 'failure') {
|
|
61
|
+
score += 300;
|
|
62
|
+
}
|
|
63
|
+
if (checks?.review === 'changes_requested') {
|
|
64
|
+
score += 250;
|
|
65
|
+
}
|
|
66
|
+
if (checks?.review === 'approved' && checks.ci !== 'failure' && checks.ci !== 'pending') {
|
|
67
|
+
score += 200;
|
|
68
|
+
}
|
|
69
|
+
if (checks?.ci === 'pending') {
|
|
70
|
+
score += 50;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (tasks.length > 0) {
|
|
74
|
+
score += 25;
|
|
75
|
+
}
|
|
76
|
+
return score;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const time = (value: string | undefined): number => {
|
|
80
|
+
const parsed = value ? Date.parse(value) : Number.NaN;
|
|
81
|
+
return Number.isNaN(parsed) ? 0 : parsed;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/** Newest activity GitHub reported, falling back to when it was opened. */
|
|
85
|
+
const activity = (pullRequest: PullRequest.PullRequest): number =>
|
|
86
|
+
time(pullRequest.updatedAt) || time(pullRequest.createdAt);
|
|
87
|
+
|
|
88
|
+
const byRecency = (left: PullRequestRow, right: PullRequestRow): number =>
|
|
89
|
+
activity(left.pullRequest) - activity(right.pullRequest) || left.pullRequest.number - right.pullRequest.number;
|
|
90
|
+
|
|
91
|
+
const compareBy: Record<PullRequestsView.SortField, (left: PullRequestRow, right: PullRequestRow) => number> = {
|
|
92
|
+
// Ties broken by recency, so equally urgent rows read newest first under the default (descending) order.
|
|
93
|
+
relevance: (left, right) => relevance(left) - relevance(right) || byRecency(left, right),
|
|
94
|
+
updated: byRecency,
|
|
95
|
+
created: (left, right) =>
|
|
96
|
+
time(left.pullRequest.createdAt) - time(right.pullRequest.createdAt) ||
|
|
97
|
+
left.pullRequest.number - right.pullRequest.number,
|
|
98
|
+
number: (left, right) => left.pullRequest.number - right.pullRequest.number,
|
|
99
|
+
title: (left, right) =>
|
|
100
|
+
(left.pullRequest.title ?? '').localeCompare(right.pullRequest.title ?? '', undefined, { sensitivity: 'base' }),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** The rows reordered by `sort`, ties kept in input order. */
|
|
104
|
+
export const sortRows = (rows: readonly PullRequestRow[], sort: PullRequestsView.Sort): readonly PullRequestRow[] => {
|
|
105
|
+
const compare = compareBy[sort.field];
|
|
106
|
+
const sign = sort.direction === 'desc' ? -1 : 1;
|
|
107
|
+
const index = new Map(rows.map((row, position) => [row.pullRequest.id, position]));
|
|
108
|
+
return [...rows].sort(
|
|
109
|
+
(left, right) =>
|
|
110
|
+
sign * compare(left, right) || (index.get(left.pullRequest.id) ?? 0) - (index.get(right.pullRequest.id) ?? 0),
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const STATE_ORDER: readonly PullRequest.State[] = ['open', 'draft', 'merged', 'closed'];
|
|
115
|
+
const STATE_ICON: Record<PullRequest.State, string> = {
|
|
116
|
+
open: 'ph--git-pull-request--regular',
|
|
117
|
+
draft: 'ph--git-pull-request--regular',
|
|
118
|
+
merged: 'ph--git-merge--regular',
|
|
119
|
+
closed: 'ph--x-circle--regular',
|
|
120
|
+
};
|
|
121
|
+
export const STATE_HUE: Record<PullRequest.State, string> = {
|
|
122
|
+
open: 'green',
|
|
123
|
+
closed: 'red',
|
|
124
|
+
merged: 'purple',
|
|
125
|
+
draft: 'neutral',
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const CI_ORDER: readonly GitHubOperation.CiState[] = ['failure', 'pending', 'success', 'none'];
|
|
129
|
+
const CI_ICON: Record<GitHubOperation.CiState, string> = {
|
|
130
|
+
failure: 'ph--x-circle--regular',
|
|
131
|
+
pending: 'ph--circle-notch--regular',
|
|
132
|
+
success: 'ph--check-circle--regular',
|
|
133
|
+
none: 'ph--minus-circle--regular',
|
|
134
|
+
};
|
|
135
|
+
export const CI_HUE: Record<GitHubOperation.CiState, string> = {
|
|
136
|
+
success: 'green',
|
|
137
|
+
failure: 'red',
|
|
138
|
+
pending: 'amber',
|
|
139
|
+
none: 'neutral',
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/** Rows partitioned by a string key, groups in first-seen order unless `order` ranks them; empty groups dropped. */
|
|
143
|
+
const partition = <K extends string>(
|
|
144
|
+
rows: readonly PullRequestRow[],
|
|
145
|
+
key: (row: PullRequestRow) => K,
|
|
146
|
+
make: (key: K, rows: readonly PullRequestRow[]) => PullRequestRowGroup,
|
|
147
|
+
order?: (left: K, right: K) => number,
|
|
148
|
+
): PullRequestRowGroup[] => {
|
|
149
|
+
const byKey = new Map<K, PullRequestRow[]>();
|
|
150
|
+
for (const row of rows) {
|
|
151
|
+
const value = key(row);
|
|
152
|
+
byKey.set(value, [...(byKey.get(value) ?? []), row]);
|
|
153
|
+
}
|
|
154
|
+
const keys = [...byKey.keys()];
|
|
155
|
+
if (order) {
|
|
156
|
+
keys.sort(order);
|
|
157
|
+
}
|
|
158
|
+
return keys.map((value) => make(value, byKey.get(value) ?? []));
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const rankOf =
|
|
162
|
+
<T extends string>(values: readonly T[]) =>
|
|
163
|
+
(left: T, right: T) =>
|
|
164
|
+
values.indexOf(left) - values.indexOf(right);
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The rows partitioned by `field`, each group's rows in input order (so a sort applies within every
|
|
168
|
+
* group). Absent for `none`: an ungrouped list has no headers.
|
|
169
|
+
*/
|
|
170
|
+
export const groupRows = (
|
|
171
|
+
rows: readonly PullRequestRow[],
|
|
172
|
+
field: PullRequestsView.GroupField,
|
|
173
|
+
): PullRequestRowGroup[] | undefined => {
|
|
174
|
+
switch (field) {
|
|
175
|
+
case 'none':
|
|
176
|
+
return undefined;
|
|
177
|
+
|
|
178
|
+
case 'repo':
|
|
179
|
+
return partition(
|
|
180
|
+
rows,
|
|
181
|
+
({ pullRequest }) => `${pullRequest.owner}/${pullRequest.repo}`,
|
|
182
|
+
(repo, rows) => ({ id: `repo-${repo}`, label: repo, icon: 'ph--git-branch--regular', rows }),
|
|
183
|
+
(left, right) => left.localeCompare(right),
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
case 'state':
|
|
187
|
+
return partition(
|
|
188
|
+
rows,
|
|
189
|
+
({ pullRequest }) => pullRequest.state,
|
|
190
|
+
(state, rows) => ({
|
|
191
|
+
id: `state-${state}`,
|
|
192
|
+
label: `pull-request-state.${state}.label`,
|
|
193
|
+
translate: true,
|
|
194
|
+
icon: STATE_ICON[state],
|
|
195
|
+
hue: STATE_HUE[state],
|
|
196
|
+
rows,
|
|
197
|
+
}),
|
|
198
|
+
rankOf(STATE_ORDER),
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
case 'checks':
|
|
202
|
+
return [
|
|
203
|
+
...partition(
|
|
204
|
+
rows.filter((row) => row.checks),
|
|
205
|
+
({ checks }): GitHubOperation.CiState => checks?.ci ?? 'none',
|
|
206
|
+
(ci, rows) => ({
|
|
207
|
+
id: `checks-${ci}`,
|
|
208
|
+
label: `ci-status.${ci}.label`,
|
|
209
|
+
translate: true,
|
|
210
|
+
icon: CI_ICON[ci],
|
|
211
|
+
hue: CI_HUE[ci],
|
|
212
|
+
rows,
|
|
213
|
+
}),
|
|
214
|
+
rankOf(CI_ORDER),
|
|
215
|
+
),
|
|
216
|
+
// Rows whose checks have not arrived (or are not fetched, e.g. a merged pull request) last.
|
|
217
|
+
...partition(
|
|
218
|
+
rows.filter((row) => !row.checks),
|
|
219
|
+
() => 'unknown' as const,
|
|
220
|
+
(_, rows) => ({
|
|
221
|
+
id: 'checks-unknown',
|
|
222
|
+
label: 'ci-status.unknown.label',
|
|
223
|
+
translate: true,
|
|
224
|
+
icon: 'ph--question--regular',
|
|
225
|
+
rows,
|
|
226
|
+
}),
|
|
227
|
+
),
|
|
228
|
+
];
|
|
229
|
+
|
|
230
|
+
case 'author':
|
|
231
|
+
return partition(
|
|
232
|
+
rows,
|
|
233
|
+
({ pullRequest }) => pullRequest.author ?? '',
|
|
234
|
+
(author, rows) => ({
|
|
235
|
+
id: `author-${author}`,
|
|
236
|
+
label: author || 'group-no-author.label',
|
|
237
|
+
translate: !author,
|
|
238
|
+
icon: author ? 'ph--user--regular' : 'ph--user-circle-dashed--regular',
|
|
239
|
+
rows,
|
|
240
|
+
}),
|
|
241
|
+
// Unknown authors last; the rest by name.
|
|
242
|
+
(left, right) => (left === '' ? 1 : right === '' ? -1 : left.localeCompare(right)),
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
const UNITS: readonly [Intl.RelativeTimeFormatUnit, number][] = [
|
|
6
|
+
['year', 365 * 24 * 60 * 60_000],
|
|
7
|
+
['month', 30 * 24 * 60 * 60_000],
|
|
8
|
+
['week', 7 * 24 * 60 * 60_000],
|
|
9
|
+
['day', 24 * 60 * 60_000],
|
|
10
|
+
['hour', 60 * 60_000],
|
|
11
|
+
['minute', 60_000],
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
// Built once: constructing an `Intl` formatter resolves the locale each time, and every row formats.
|
|
15
|
+
let formatter: Intl.RelativeTimeFormat | undefined;
|
|
16
|
+
|
|
17
|
+
/** `5 minutes ago`, `yesterday`, `3 weeks ago` — in the largest unit that fits; empty for an invalid date. */
|
|
18
|
+
export const formatRelative = (value: string, now = Date.now()): string => {
|
|
19
|
+
const date = Date.parse(value);
|
|
20
|
+
if (Number.isNaN(date)) {
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
formatter ??= new Intl.RelativeTimeFormat(undefined, { numeric: 'auto' });
|
|
24
|
+
const elapsed = date - now;
|
|
25
|
+
for (const [unit, size] of UNITS) {
|
|
26
|
+
if (Math.abs(elapsed) >= size) {
|
|
27
|
+
return formatter.format(Math.round(elapsed / size), unit);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return formatter.format(0, 'minute');
|
|
31
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import type * as AppSurface from '@dxos/app-toolkit/AppSurface';
|
|
8
|
+
import { Filter, Obj } from '@dxos/echo';
|
|
9
|
+
import { useObject, useQuery } from '@dxos/echo-react';
|
|
10
|
+
import { PullRequest } from '@dxos/types';
|
|
11
|
+
|
|
12
|
+
import { type Walkthrough } from '#types';
|
|
13
|
+
|
|
14
|
+
import { PullRequestArticle } from '../PullRequestArticle/PullRequestArticle.tsx';
|
|
15
|
+
|
|
16
|
+
export type WalkthroughArticleProps = AppSurface.ObjectArticleProps<Walkthrough.Walkthrough>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A walkthrough opened directly — from a search result, or a link written before the pull request
|
|
20
|
+
* became the subject — shown as the review of the pull request it narrates.
|
|
21
|
+
*
|
|
22
|
+
* The ref is resolved to a snapshot and the live object queried back by id: the article writes to
|
|
23
|
+
* the pull request (approve, comment) through a ref of its own, which a snapshot cannot give.
|
|
24
|
+
*/
|
|
25
|
+
export const WalkthroughArticle = ({ subject, ...props }: WalkthroughArticleProps) => {
|
|
26
|
+
const [target] = useObject(subject.pullRequest);
|
|
27
|
+
const objects = useQuery(Obj.getDatabase(subject), target ? Filter.id(target.id) : Filter.nothing());
|
|
28
|
+
const pullRequest = objects.find(PullRequest.instanceOf);
|
|
29
|
+
|
|
30
|
+
return pullRequest ? <PullRequestArticle {...props} subject={pullRequest} /> : null;
|
|
31
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ComponentType, lazy } from 'react';
|
|
6
|
+
|
|
7
|
+
export const ImportPullRequestDialog: ComponentType<any> = lazy(() => import('./ImportPullRequestDialog/index.ts'));
|
|
8
|
+
export const PullRequestCardMenu: ComponentType<any> = lazy(() => import('./PullRequestCardMenu/index.ts'));
|
|
9
|
+
export const PullRequestArticle: ComponentType<any> = lazy(() => import('./PullRequestArticle/index.ts'));
|
|
10
|
+
export const PullRequestsArticle: ComponentType<any> = lazy(() => import('./PullRequestsArticle/index.ts'));
|
|
11
|
+
export const WalkthroughArticle: ComponentType<any> = lazy(() => import('./WalkthroughArticle/index.ts'));
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Predicate from 'effect/Predicate';
|
|
6
|
+
|
|
7
|
+
import { BaseError } from '@dxos/errors';
|
|
8
|
+
|
|
9
|
+
/** The binding names no repository: no `externalId` and no GitHub foreign key on the target. */
|
|
10
|
+
export class GitHubRepoUnresolvedError extends BaseError.extend(
|
|
11
|
+
'GitHubRepoUnresolvedError',
|
|
12
|
+
'Binding does not name a GitHub repository.',
|
|
13
|
+
) {}
|
|
14
|
+
|
|
15
|
+
/** The connection's token cannot see the repository the binding names (un-shared or revoked). */
|
|
16
|
+
export class GitHubRepoInaccessibleError extends BaseError.extend(
|
|
17
|
+
'GitHubRepoInaccessibleError',
|
|
18
|
+
'Repository is not accessible to the connection token.',
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
/** The pull request is not stored: a preview card mints one in memory, and it has no database. */
|
|
22
|
+
export class GitHubPullRequestUnstoredError extends BaseError.extend(
|
|
23
|
+
'GitHubPullRequestUnstoredError',
|
|
24
|
+
'Pull request is not stored in a space.',
|
|
25
|
+
) {}
|
|
26
|
+
|
|
27
|
+
/** The text a user typed names no pull request: neither a github.com URL nor `owner/repo#123`. */
|
|
28
|
+
export class GitHubPullRequestReferenceError extends BaseError.extend(
|
|
29
|
+
'GitHubPullRequestReferenceError',
|
|
30
|
+
'Not a pull request reference.',
|
|
31
|
+
) {}
|
|
32
|
+
|
|
33
|
+
/** The local Project could not be re-resolved after its upsert. */
|
|
34
|
+
export class GitHubProjectMissingError extends BaseError.extend(
|
|
35
|
+
'GitHubProjectMissingError',
|
|
36
|
+
'Local project missing after upsert.',
|
|
37
|
+
) {}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* User-facing / persisted diagnostic string for failures from GitHub sync paths.
|
|
41
|
+
*/
|
|
42
|
+
export const formatGitHubSyncFailure = (error: unknown): string => {
|
|
43
|
+
if (error instanceof BaseError) {
|
|
44
|
+
const keys = Object.keys(error.context);
|
|
45
|
+
return keys.length > 0 ? `${error.name}: ${JSON.stringify(error.context)}` : error.name;
|
|
46
|
+
}
|
|
47
|
+
if (Predicate.isObject(error) && typeof error._tag === 'string') {
|
|
48
|
+
if (
|
|
49
|
+
error._tag === 'ResponseError' &&
|
|
50
|
+
Predicate.isObject(error.response) &&
|
|
51
|
+
typeof error.response.status === 'number'
|
|
52
|
+
) {
|
|
53
|
+
return `HTTP ${error.response.status}`;
|
|
54
|
+
}
|
|
55
|
+
return error._tag;
|
|
56
|
+
}
|
|
57
|
+
if (error instanceof Error) {
|
|
58
|
+
return error.message;
|
|
59
|
+
}
|
|
60
|
+
return String(error);
|
|
61
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
// @vitest-environment happy-dom
|
|
5
|
+
|
|
6
|
+
import { forceParsing } from '@codemirror/language';
|
|
7
|
+
import { EditorState } from '@codemirror/state';
|
|
8
|
+
import { EditorView, WidgetType } from '@codemirror/view';
|
|
9
|
+
import { describe, test } from 'vitest';
|
|
10
|
+
|
|
11
|
+
import { AnchorWidget, type WidgetDef, createMarkdownExtensions, decorationSetToArray } from '@dxos/ui-editor';
|
|
12
|
+
|
|
13
|
+
import { parseGitHubLink, parsePullRequestReference } from '../github-link.ts';
|
|
14
|
+
import { type GitHubLinkProps, githubLinks } from './links.ts';
|
|
15
|
+
|
|
16
|
+
/** Widget whose props are inspectable so tests can assert what the factory was handed. */
|
|
17
|
+
class TestWidget extends WidgetType {
|
|
18
|
+
constructor(readonly props: GitHubLinkProps) {
|
|
19
|
+
super();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override eq(other: this): boolean {
|
|
23
|
+
return other instanceof TestWidget && other.props.url === this.props.url;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override toDOM(): HTMLElement {
|
|
27
|
+
return document.createElement('span');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const widgets = <T extends WidgetType>(doc: string, link?: WidgetDef<GitHubLinkProps>): T[] => {
|
|
32
|
+
const view = new EditorView({
|
|
33
|
+
state: EditorState.create({ doc, extensions: [createMarkdownExtensions(), githubLinks({ link })] }),
|
|
34
|
+
parent: document.createElement('div'),
|
|
35
|
+
});
|
|
36
|
+
forceParsing(view, view.state.doc.length, 5_000);
|
|
37
|
+
const out: T[] = [];
|
|
38
|
+
for (const source of view.state.facet(EditorView.decorations)) {
|
|
39
|
+
const set = typeof source === 'function' ? source(view) : source;
|
|
40
|
+
if (!set) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
for (const { value } of decorationSetToArray(set)) {
|
|
44
|
+
if (value.spec?.widget instanceof WidgetType) {
|
|
45
|
+
out.push(value.spec.widget as T);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
view.destroy();
|
|
50
|
+
return out;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
describe('githubLinks', () => {
|
|
54
|
+
test('parses repository, pull request and issue URLs', ({ expect }) => {
|
|
55
|
+
expect(parseGitHubLink('https://github.com/dxos/dxos/pull/13031')).toEqual({
|
|
56
|
+
owner: 'dxos',
|
|
57
|
+
repo: 'dxos',
|
|
58
|
+
kind: 'pull',
|
|
59
|
+
number: 13031,
|
|
60
|
+
url: 'https://github.com/dxos/dxos/pull/13031',
|
|
61
|
+
});
|
|
62
|
+
expect(parseGitHubLink('https://github.com/dxos/dxos/issues/12?x=1#top')?.kind).toBe('issue');
|
|
63
|
+
expect(parseGitHubLink('https://github.com/dxos/dxos')).toEqual({
|
|
64
|
+
owner: 'dxos',
|
|
65
|
+
repo: 'dxos',
|
|
66
|
+
kind: 'repo',
|
|
67
|
+
url: 'https://github.com/dxos/dxos',
|
|
68
|
+
});
|
|
69
|
+
expect(parseGitHubLink('https://github.com/dxos/dxos/#readme')?.kind).toBe('repo');
|
|
70
|
+
expect(parseGitHubLink('https://github.com/dxos/dxos/blob/main/README.md')).toBeUndefined();
|
|
71
|
+
expect(parseGitHubLink('https://github.com/dxos')).toBeUndefined();
|
|
72
|
+
expect(parseGitHubLink('https://example.com/dxos/dxos/pull/1')).toBeUndefined();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('a pull request link becomes an anchor chip; other links are left alone', ({ expect }) => {
|
|
76
|
+
const found = widgets<AnchorWidget>(
|
|
77
|
+
'See [the fix](https://github.com/dxos/dxos/pull/13031) and [docs](https://example.com).',
|
|
78
|
+
);
|
|
79
|
+
expect(found.every((widget) => widget instanceof AnchorWidget)).toBe(true);
|
|
80
|
+
expect(found.map((widget) => widget._dxn)).toEqual(['https://github.com/dxos/dxos/pull/13031']);
|
|
81
|
+
expect(found[0]._label).toBe('the fix');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('a host-provided link widget receives the parsed parts with the link props', ({ expect }) => {
|
|
85
|
+
const found = widgets<TestWidget>('Fixed in [#7](https://github.com/dxos/dxos/issues/7).', {
|
|
86
|
+
factory: (props) => new TestWidget(props),
|
|
87
|
+
});
|
|
88
|
+
expect(found).toHaveLength(1);
|
|
89
|
+
expect(found[0].props).toMatchObject({
|
|
90
|
+
label: '#7',
|
|
91
|
+
url: 'https://github.com/dxos/dxos/issues/7',
|
|
92
|
+
owner: 'dxos',
|
|
93
|
+
repo: 'dxos',
|
|
94
|
+
kind: 'issue',
|
|
95
|
+
number: 7,
|
|
96
|
+
block: false,
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('a pull request reference is read from a URL or from owner/repo#number', ({ expect }) => {
|
|
101
|
+
expect(parsePullRequestReference('dxos/dxos#13031')).toEqual({ owner: 'dxos', repo: 'dxos', number: 13031 });
|
|
102
|
+
expect(parsePullRequestReference(' dxos/dxos#13031 ')).toEqual({ owner: 'dxos', repo: 'dxos', number: 13031 });
|
|
103
|
+
expect(parsePullRequestReference('https://github.com/dxos/dxos/pull/13031')).toEqual({
|
|
104
|
+
owner: 'dxos',
|
|
105
|
+
repo: 'dxos',
|
|
106
|
+
number: 13031,
|
|
107
|
+
});
|
|
108
|
+
// GitHub serves a pull request under its issue URL too, so the reader who copied that one still
|
|
109
|
+
// named the same change.
|
|
110
|
+
expect(parsePullRequestReference('https://github.com/dxos/dxos/issues/7')).toEqual({
|
|
111
|
+
owner: 'dxos',
|
|
112
|
+
repo: 'dxos',
|
|
113
|
+
number: 7,
|
|
114
|
+
});
|
|
115
|
+
expect(parsePullRequestReference('https://github.com/dxos/dxos')).toBeUndefined();
|
|
116
|
+
expect(parsePullRequestReference('dxos/dxos')).toBeUndefined();
|
|
117
|
+
expect(parsePullRequestReference('#13031')).toBeUndefined();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// The extension's page action matches `https://github.com/*/*/pull/*` and passes the page's URL
|
|
121
|
+
// straight through, so every URL that pattern admits must name a pull request here.
|
|
122
|
+
test('every pull request page the extension matches is a readable reference', ({ expect }) => {
|
|
123
|
+
for (const url of [
|
|
124
|
+
'https://github.com/dxos/dxos/pull/1',
|
|
125
|
+
'https://github.com/dxos/dxos/pull/1/files',
|
|
126
|
+
'https://github.com/dxos/dxos/pull/1/commits',
|
|
127
|
+
'https://github.com/dxos/dxos/pull/1#issuecomment-1',
|
|
128
|
+
'https://github.com/dxos/dxos/pull/1?w=1',
|
|
129
|
+
]) {
|
|
130
|
+
expect(parsePullRequestReference(url), url).toEqual({ owner: 'dxos', repo: 'dxos', number: 1 });
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Extension } from '@codemirror/state';
|
|
6
|
+
import { createElement } from 'react';
|
|
7
|
+
|
|
8
|
+
import { AnchorWidget, type LinkWidgetProps, type WidgetDef, linkWidgets, matchPattern } from '@dxos/ui-editor';
|
|
9
|
+
|
|
10
|
+
import { GITHUB_LINK, type GitHubLink, parseGitHubLink } from '../github-link.ts';
|
|
11
|
+
|
|
12
|
+
export * from '../github-link.ts';
|
|
13
|
+
|
|
14
|
+
/** A link widget's props, with the URL's parts alongside it. */
|
|
15
|
+
export type GitHubLinkProps<TContext = any> = LinkWidgetProps<TContext> & GitHubLink;
|
|
16
|
+
|
|
17
|
+
/** The chip's leading icon for a pull request, in GitHub's open-state green. */
|
|
18
|
+
export const PULL_REQUEST_ICON = { icon: 'ph--git-pull-request--regular', classNames: 'text-green-500' };
|
|
19
|
+
|
|
20
|
+
/** The chip icon for a GitHub URL: a pull request's; none for an issue or a repository. */
|
|
21
|
+
export const githubLinkIcon = (url: string): typeof PULL_REQUEST_ICON | undefined =>
|
|
22
|
+
parseGitHubLink(url)?.kind === 'pull' ? PULL_REQUEST_ICON : undefined;
|
|
23
|
+
|
|
24
|
+
export type GitHubLinksOptions = {
|
|
25
|
+
/** Overrides the default chip's preview trigger. */
|
|
26
|
+
trigger?: 'hover' | 'click';
|
|
27
|
+
/** The inline widget for `[label](https://github.com/…/pull/123)`; the anchor chip by default. */
|
|
28
|
+
link?: WidgetDef<GitHubLinkProps>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* GitHub pull request and issue links as widgets: a `linkWidgets` matcher on the URL's shape rather
|
|
33
|
+
* than its scheme, whose widget gets the parsed parts. The default anchor chip carries the URL to
|
|
34
|
+
* the preview popover, where this plugin's link resolver answers with the pull request or issue.
|
|
35
|
+
* Contributed through `MarkdownCapabilities.ExtensionProvider` rather than built into the editor.
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* What a chip says for a link the reader wrote as a bare URL: `#123`, or `owner/repo` for a
|
|
39
|
+
* repository. The URL is its own text in that form, and a chip repeating it is longer than the text
|
|
40
|
+
* it replaced — the read-only renderer makes the same substitution.
|
|
41
|
+
*/
|
|
42
|
+
const bareLabel = ({ number, owner, repo }: GitHubLink): string => (number ? `#${number}` : `${owner}/${repo}`);
|
|
43
|
+
|
|
44
|
+
export const githubLinks = ({
|
|
45
|
+
trigger,
|
|
46
|
+
link = {
|
|
47
|
+
factory: (props) =>
|
|
48
|
+
new AnchorWidget(
|
|
49
|
+
props.label === props.url ? bareLabel(props) : props.label,
|
|
50
|
+
props.url,
|
|
51
|
+
trigger,
|
|
52
|
+
undefined,
|
|
53
|
+
props.kind === 'pull' ? PULL_REQUEST_ICON : undefined,
|
|
54
|
+
),
|
|
55
|
+
},
|
|
56
|
+
}: GitHubLinksOptions = {}): Extension =>
|
|
57
|
+
linkWidgets({
|
|
58
|
+
match: matchPattern(GITHUB_LINK),
|
|
59
|
+
link: withGitHubLink(link),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/** The definition over link props, with the URL parsed into the parts the GitHub-side code reads. */
|
|
63
|
+
const withGitHubLink = (def: WidgetDef<GitHubLinkProps>): WidgetDef<LinkWidgetProps> => {
|
|
64
|
+
const { factory, Component, estimatedHeight, ...rest } = def;
|
|
65
|
+
const githubProps = (props: LinkWidgetProps): GitHubLinkProps | undefined => {
|
|
66
|
+
const link = parseGitHubLink(props.url);
|
|
67
|
+
return link && { ...props, ...link };
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
...rest,
|
|
72
|
+
...(factory && {
|
|
73
|
+
factory: (props) => {
|
|
74
|
+
const parsed = githubProps(props);
|
|
75
|
+
return parsed ? factory(parsed) : null;
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
...(Component && {
|
|
79
|
+
Component: (props) => {
|
|
80
|
+
const parsed = githubProps(props);
|
|
81
|
+
return parsed ? createElement(Component, parsed) : null;
|
|
82
|
+
},
|
|
83
|
+
}),
|
|
84
|
+
...(estimatedHeight && {
|
|
85
|
+
estimatedHeight: (props) => {
|
|
86
|
+
const parsed = githubProps(props);
|
|
87
|
+
return parsed ? estimatedHeight(parsed) : 0;
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
};
|
|
91
|
+
};
|