@self-review/serve 1.45.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/README.md +128 -0
- package/dist/cli.js +839 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/assets/_basePickBy-DzL66huQ.js +1 -0
- package/dist/client/assets/_baseUniq-D_kA9hnK.js +1 -0
- package/dist/client/assets/arc-LxCcHggQ.js +1 -0
- package/dist/client/assets/architectureDiagram-VXUJARFQ-BmSW2FCh.js +36 -0
- package/dist/client/assets/blockDiagram-VD42YOAC-Duz6oS5b.js +122 -0
- package/dist/client/assets/c4Diagram-YG6GDRKO-Bv4P72yB.js +10 -0
- package/dist/client/assets/channel-ydExFSqY.js +1 -0
- package/dist/client/assets/chunk-4BX2VUAB-D2GfUqwd.js +1 -0
- package/dist/client/assets/chunk-55IACEB6-C68L7s0h.js +1 -0
- package/dist/client/assets/chunk-B4BG7PRW-BtVwfswM.js +165 -0
- package/dist/client/assets/chunk-DI55MBZ5-BDdO91wt.js +220 -0
- package/dist/client/assets/chunk-FMBD7UC4-tB9OepVI.js +15 -0
- package/dist/client/assets/chunk-QN33PNHL-HjKgp1PB.js +1 -0
- package/dist/client/assets/chunk-QZHKN3VN-GT04-vw7.js +1 -0
- package/dist/client/assets/chunk-TZMSLE5B-DpxXSXMp.js +1 -0
- package/dist/client/assets/classDiagram-2ON5EDUG-Dg8dmmRD.js +1 -0
- package/dist/client/assets/classDiagram-v2-WZHVMYZB-Dg8dmmRD.js +1 -0
- package/dist/client/assets/clone-Bq6xpRgi.js +1 -0
- package/dist/client/assets/cose-bilkent-S5V4N54A-Ds41oEbD.js +1 -0
- package/dist/client/assets/cytoscape.esm-5J0xJHOV.js +321 -0
- package/dist/client/assets/dagre-6UL2VRFP-DZiEousR.js +4 -0
- package/dist/client/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/client/assets/diagram-PSM6KHXK-0_alnUMs.js +24 -0
- package/dist/client/assets/diagram-QEK2KX5R-KFaKVdU8.js +43 -0
- package/dist/client/assets/diagram-S2PKOQOG-C2Dy10VG.js +24 -0
- package/dist/client/assets/erDiagram-Q2GNP2WA-_P7rrcgu.js +60 -0
- package/dist/client/assets/flowDiagram-NV44I4VS-BvC6gSn5.js +162 -0
- package/dist/client/assets/ganttDiagram-JELNMOA3-DjzuVPeB.js +267 -0
- package/dist/client/assets/gitGraphDiagram-V2S2FVAM-B9fPDqqA.js +65 -0
- package/dist/client/assets/graph-BqLQdgDA.js +1 -0
- package/dist/client/assets/index-CAXQd1OO.js +286 -0
- package/dist/client/assets/index-CmSvc3Wo.css +1 -0
- package/dist/client/assets/infoDiagram-HS3SLOUP-DiMCwlkY.js +2 -0
- package/dist/client/assets/init-Gi6I4Gst.js +1 -0
- package/dist/client/assets/journeyDiagram-XKPGCS4Q-Dn5WdzPP.js +139 -0
- package/dist/client/assets/kanban-definition-3W4ZIXB7-D-BINTOt.js +89 -0
- package/dist/client/assets/katex-DhXJpUyf.js +261 -0
- package/dist/client/assets/layout-Bo5pDIcD.js +1 -0
- package/dist/client/assets/linear-CNmY37sq.js +1 -0
- package/dist/client/assets/mermaid.core-DfADLZQ1.js +250 -0
- package/dist/client/assets/mindmap-definition-VGOIOE7T-H5HwEwuX.js +68 -0
- package/dist/client/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/client/assets/pieDiagram-ADFJNKIX-RiZa5XQN.js +30 -0
- package/dist/client/assets/quadrantDiagram-AYHSOK5B-CFFX55h2.js +7 -0
- package/dist/client/assets/requirementDiagram-UZGBJVZJ-B6JBcV1I.js +64 -0
- package/dist/client/assets/sankeyDiagram-TZEHDZUN-GZT80dnc.js +10 -0
- package/dist/client/assets/sequenceDiagram-WL72ISMW-CbUqoUma.js +145 -0
- package/dist/client/assets/stateDiagram-FKZM4ZOC-LEb-ZQVV.js +1 -0
- package/dist/client/assets/stateDiagram-v2-4FDKWEC3-BYGHA8iw.js +1 -0
- package/dist/client/assets/timeline-definition-IT6M3QCI-Cm1Kd50N.js +61 -0
- package/dist/client/assets/treemap-GDKQZRPO-CWXk-dEb.js +160 -0
- package/dist/client/assets/xychartDiagram-PRI3JC2R-BUllxp6G.js +7 -0
- package/dist/client/index.html +29 -0
- package/dist/core/src/apply-suggestion.d.ts +76 -0
- package/dist/core/src/apply-suggestion.d.ts.map +1 -0
- package/dist/core/src/apply-suggestion.js +109 -0
- package/dist/core/src/apply-suggestion.js.map +1 -0
- package/dist/core/src/config.d.ts +3 -0
- package/dist/core/src/config.d.ts.map +1 -0
- package/dist/core/src/config.js +196 -0
- package/dist/core/src/config.js.map +1 -0
- package/dist/core/src/diff-parser.d.ts +3 -0
- package/dist/core/src/diff-parser.d.ts.map +1 -0
- package/dist/core/src/diff-parser.js +236 -0
- package/dist/core/src/diff-parser.js.map +1 -0
- package/dist/core/src/directory-scanner.d.ts +18 -0
- package/dist/core/src/directory-scanner.d.ts.map +1 -0
- package/dist/core/src/directory-scanner.js +99 -0
- package/dist/core/src/directory-scanner.js.map +1 -0
- package/dist/core/src/fetch-comments.d.ts +69 -0
- package/dist/core/src/fetch-comments.d.ts.map +1 -0
- package/dist/core/src/fetch-comments.js +180 -0
- package/dist/core/src/fetch-comments.js.map +1 -0
- package/dist/core/src/file-type-utils.d.ts +16 -0
- package/dist/core/src/file-type-utils.d.ts.map +1 -0
- package/dist/core/src/file-type-utils.js +106 -0
- package/dist/core/src/file-type-utils.js.map +1 -0
- package/dist/core/src/forge-provider.d.ts +123 -0
- package/dist/core/src/forge-provider.d.ts.map +1 -0
- package/dist/core/src/forge-provider.js +68 -0
- package/dist/core/src/forge-provider.js.map +1 -0
- package/dist/core/src/fs-utils.d.ts +7 -0
- package/dist/core/src/fs-utils.d.ts.map +1 -0
- package/dist/core/src/fs-utils.js +20 -0
- package/dist/core/src/fs-utils.js.map +1 -0
- package/dist/core/src/git-diff-args.d.ts +38 -0
- package/dist/core/src/git-diff-args.d.ts.map +1 -0
- package/dist/core/src/git-diff-args.js +170 -0
- package/dist/core/src/git-diff-args.js.map +1 -0
- package/dist/core/src/git-diff-loader.d.ts +14 -0
- package/dist/core/src/git-diff-loader.d.ts.map +1 -0
- package/dist/core/src/git-diff-loader.js +30 -0
- package/dist/core/src/git-diff-loader.js.map +1 -0
- package/dist/core/src/git.d.ts +52 -0
- package/dist/core/src/git.d.ts.map +1 -0
- package/dist/core/src/git.js +191 -0
- package/dist/core/src/git.js.map +1 -0
- package/dist/core/src/github-provider.d.ts +7 -0
- package/dist/core/src/github-provider.d.ts.map +1 -0
- package/dist/core/src/github-provider.js +151 -0
- package/dist/core/src/github-provider.js.map +1 -0
- package/dist/core/src/gitlab-provider.d.ts +10 -0
- package/dist/core/src/gitlab-provider.d.ts.map +1 -0
- package/dist/core/src/gitlab-provider.js +207 -0
- package/dist/core/src/gitlab-provider.js.map +1 -0
- package/dist/core/src/guide-loader.d.ts +23 -0
- package/dist/core/src/guide-loader.d.ts.map +1 -0
- package/dist/core/src/guide-loader.js +95 -0
- package/dist/core/src/guide-loader.js.map +1 -0
- package/dist/core/src/guide-parser.d.ts +34 -0
- package/dist/core/src/guide-parser.d.ts.map +1 -0
- package/dist/core/src/guide-parser.js +136 -0
- package/dist/core/src/guide-parser.js.map +1 -0
- package/dist/core/src/guide-schema.d.ts +2 -0
- package/dist/core/src/guide-schema.d.ts.map +1 -0
- package/dist/core/src/guide-schema.js +202 -0
- package/dist/core/src/guide-schema.js.map +1 -0
- package/dist/core/src/ignore-filter.d.ts +8 -0
- package/dist/core/src/ignore-filter.d.ts.map +1 -0
- package/dist/core/src/ignore-filter.js +16 -0
- package/dist/core/src/ignore-filter.js.map +1 -0
- package/dist/core/src/index.d.ts +38 -0
- package/dist/core/src/index.d.ts.map +1 -0
- package/dist/core/src/index.js +54 -0
- package/dist/core/src/index.js.map +1 -0
- package/dist/core/src/materializer.d.ts +60 -0
- package/dist/core/src/materializer.d.ts.map +1 -0
- package/dist/core/src/materializer.js +255 -0
- package/dist/core/src/materializer.js.map +1 -0
- package/dist/core/src/payload-sizing.d.ts +20 -0
- package/dist/core/src/payload-sizing.d.ts.map +1 -0
- package/dist/core/src/payload-sizing.js +74 -0
- package/dist/core/src/payload-sizing.js.map +1 -0
- package/dist/core/src/remote-mode.d.ts +89 -0
- package/dist/core/src/remote-mode.d.ts.map +1 -0
- package/dist/core/src/remote-mode.js +193 -0
- package/dist/core/src/remote-mode.js.map +1 -0
- package/dist/core/src/review-handlers.d.ts +160 -0
- package/dist/core/src/review-handlers.d.ts.map +1 -0
- package/dist/core/src/review-handlers.js +463 -0
- package/dist/core/src/review-handlers.js.map +1 -0
- package/dist/core/src/staged-untracked.d.ts +12 -0
- package/dist/core/src/staged-untracked.d.ts.map +1 -0
- package/dist/core/src/staged-untracked.js +21 -0
- package/dist/core/src/staged-untracked.js.map +1 -0
- package/dist/core/src/startup-mode.d.ts +6 -0
- package/dist/core/src/startup-mode.d.ts.map +1 -0
- package/dist/core/src/startup-mode.js +73 -0
- package/dist/core/src/startup-mode.js.map +1 -0
- package/dist/core/src/synthetic-diff.d.ts +21 -0
- package/dist/core/src/synthetic-diff.d.ts.map +1 -0
- package/dist/core/src/synthetic-diff.js +104 -0
- package/dist/core/src/synthetic-diff.js.map +1 -0
- package/dist/core/src/thread-mapper.d.ts +39 -0
- package/dist/core/src/thread-mapper.d.ts.map +1 -0
- package/dist/core/src/thread-mapper.js +217 -0
- package/dist/core/src/thread-mapper.js.map +1 -0
- package/dist/core/src/types.d.ts +2 -0
- package/dist/core/src/types.d.ts.map +1 -0
- package/dist/core/src/types.js +2 -0
- package/dist/core/src/types.js.map +1 -0
- package/dist/core/src/xml-parser.d.ts +15 -0
- package/dist/core/src/xml-parser.d.ts.map +1 -0
- package/dist/core/src/xml-parser.js +237 -0
- package/dist/core/src/xml-parser.js.map +1 -0
- package/dist/core/src/xml-serializer.d.ts +4 -0
- package/dist/core/src/xml-serializer.d.ts.map +1 -0
- package/dist/core/src/xml-serializer.js +923 -0
- package/dist/core/src/xml-serializer.js.map +1 -0
- package/dist/react/src/ReviewPanel.d.ts +72 -0
- package/dist/react/src/ReviewPanel.d.ts.map +1 -0
- package/dist/react/src/ReviewPanel.js +51 -0
- package/dist/react/src/ReviewPanel.js.map +1 -0
- package/dist/react/src/SingleFileReview.d.ts +49 -0
- package/dist/react/src/SingleFileReview.d.ts.map +1 -0
- package/dist/react/src/SingleFileReview.js +41 -0
- package/dist/react/src/SingleFileReview.js.map +1 -0
- package/dist/react/src/adapter.d.ts +72 -0
- package/dist/react/src/adapter.d.ts.map +1 -0
- package/dist/react/src/adapter.js +2 -0
- package/dist/react/src/adapter.js.map +1 -0
- package/dist/react/src/components/Comments/AttachmentDropZone.d.ts +10 -0
- package/dist/react/src/components/Comments/AttachmentDropZone.d.ts.map +1 -0
- package/dist/react/src/components/Comments/AttachmentDropZone.js +52 -0
- package/dist/react/src/components/Comments/AttachmentDropZone.js.map +1 -0
- package/dist/react/src/components/Comments/AttachmentImage.d.ts +6 -0
- package/dist/react/src/components/Comments/AttachmentImage.d.ts.map +1 -0
- package/dist/react/src/components/Comments/AttachmentImage.js +50 -0
- package/dist/react/src/components/Comments/AttachmentImage.js.map +1 -0
- package/dist/react/src/components/Comments/AttachmentThumbnail.d.ts +6 -0
- package/dist/react/src/components/Comments/AttachmentThumbnail.d.ts.map +1 -0
- package/dist/react/src/components/Comments/AttachmentThumbnail.js +16 -0
- package/dist/react/src/components/Comments/AttachmentThumbnail.js.map +1 -0
- package/dist/react/src/components/Comments/CategorySelector.d.ts +6 -0
- package/dist/react/src/components/Comments/CategorySelector.d.ts.map +1 -0
- package/dist/react/src/components/Comments/CategorySelector.js +27 -0
- package/dist/react/src/components/Comments/CategorySelector.js.map +1 -0
- package/dist/react/src/components/Comments/CommentDisplay.d.ts +7 -0
- package/dist/react/src/components/Comments/CommentDisplay.d.ts.map +1 -0
- package/dist/react/src/components/Comments/CommentDisplay.js +103 -0
- package/dist/react/src/components/Comments/CommentDisplay.js.map +1 -0
- package/dist/react/src/components/Comments/CommentInput.d.ts +11 -0
- package/dist/react/src/components/Comments/CommentInput.d.ts.map +1 -0
- package/dist/react/src/components/Comments/CommentInput.js +81 -0
- package/dist/react/src/components/Comments/CommentInput.js.map +1 -0
- package/dist/react/src/components/Comments/ComposerCore.d.ts +49 -0
- package/dist/react/src/components/Comments/ComposerCore.d.ts.map +1 -0
- package/dist/react/src/components/Comments/ComposerCore.js +91 -0
- package/dist/react/src/components/Comments/ComposerCore.js.map +1 -0
- package/dist/react/src/components/Comments/EmojiAutocomplete.d.ts +14 -0
- package/dist/react/src/components/Comments/EmojiAutocomplete.d.ts.map +1 -0
- package/dist/react/src/components/Comments/EmojiAutocomplete.js +19 -0
- package/dist/react/src/components/Comments/EmojiAutocomplete.js.map +1 -0
- package/dist/react/src/components/Comments/ReplyDisplay.d.ts +22 -0
- package/dist/react/src/components/Comments/ReplyDisplay.d.ts.map +1 -0
- package/dist/react/src/components/Comments/ReplyDisplay.js +38 -0
- package/dist/react/src/components/Comments/ReplyDisplay.js.map +1 -0
- package/dist/react/src/components/Comments/ReplyInput.d.ts +9 -0
- package/dist/react/src/components/Comments/ReplyInput.d.ts.map +1 -0
- package/dist/react/src/components/Comments/ReplyInput.js +47 -0
- package/dist/react/src/components/Comments/ReplyInput.js.map +1 -0
- package/dist/react/src/components/Comments/SuggestionApplyControl.d.ts +27 -0
- package/dist/react/src/components/Comments/SuggestionApplyControl.d.ts.map +1 -0
- package/dist/react/src/components/Comments/SuggestionApplyControl.js +103 -0
- package/dist/react/src/components/Comments/SuggestionApplyControl.js.map +1 -0
- package/dist/react/src/components/Comments/SuggestionBlock.d.ts +26 -0
- package/dist/react/src/components/Comments/SuggestionBlock.d.ts.map +1 -0
- package/dist/react/src/components/Comments/SuggestionBlock.js +33 -0
- package/dist/react/src/components/Comments/SuggestionBlock.js.map +1 -0
- package/dist/react/src/components/Comments/SuggestionPanel.d.ts +8 -0
- package/dist/react/src/components/Comments/SuggestionPanel.d.ts.map +1 -0
- package/dist/react/src/components/Comments/SuggestionPanel.js +12 -0
- package/dist/react/src/components/Comments/SuggestionPanel.js.map +1 -0
- package/dist/react/src/components/DiffViewer/DiffContentArea.d.ts +35 -0
- package/dist/react/src/components/DiffViewer/DiffContentArea.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/DiffContentArea.js +40 -0
- package/dist/react/src/components/DiffViewer/DiffContentArea.js.map +1 -0
- package/dist/react/src/components/DiffViewer/DiffViewer.d.ts +4 -0
- package/dist/react/src/components/DiffViewer/DiffViewer.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/DiffViewer.js +110 -0
- package/dist/react/src/components/DiffViewer/DiffViewer.js.map +1 -0
- package/dist/react/src/components/DiffViewer/EmptyDiffMessage.d.ts +6 -0
- package/dist/react/src/components/DiffViewer/EmptyDiffMessage.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/EmptyDiffMessage.js +18 -0
- package/dist/react/src/components/DiffViewer/EmptyDiffMessage.js.map +1 -0
- package/dist/react/src/components/DiffViewer/EmptyLinePane.d.ts +2 -0
- package/dist/react/src/components/DiffViewer/EmptyLinePane.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/EmptyLinePane.js +5 -0
- package/dist/react/src/components/DiffViewer/EmptyLinePane.js.map +1 -0
- package/dist/react/src/components/DiffViewer/ExpandContextBar.d.ts +10 -0
- package/dist/react/src/components/DiffViewer/ExpandContextBar.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/ExpandContextBar.js +16 -0
- package/dist/react/src/components/DiffViewer/ExpandContextBar.js.map +1 -0
- package/dist/react/src/components/DiffViewer/FileSection.d.ts +9 -0
- package/dist/react/src/components/DiffViewer/FileSection.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/FileSection.js +137 -0
- package/dist/react/src/components/DiffViewer/FileSection.js.map +1 -0
- package/dist/react/src/components/DiffViewer/FileSectionBody.d.ts +13 -0
- package/dist/react/src/components/DiffViewer/FileSectionBody.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/FileSectionBody.js +8 -0
- package/dist/react/src/components/DiffViewer/FileSectionBody.js.map +1 -0
- package/dist/react/src/components/DiffViewer/FileSectionHeader.d.ts +16 -0
- package/dist/react/src/components/DiffViewer/FileSectionHeader.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/FileSectionHeader.js +53 -0
- package/dist/react/src/components/DiffViewer/FileSectionHeader.js.map +1 -0
- package/dist/react/src/components/DiffViewer/FrontMatterTable.d.ts +6 -0
- package/dist/react/src/components/DiffViewer/FrontMatterTable.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/FrontMatterTable.js +30 -0
- package/dist/react/src/components/DiffViewer/FrontMatterTable.js.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideChapterDivider.d.ts +20 -0
- package/dist/react/src/components/DiffViewer/GuideChapterDivider.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideChapterDivider.js +27 -0
- package/dist/react/src/components/DiffViewer/GuideChapterDivider.js.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewContent.d.ts +16 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewContent.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewContent.js +56 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewContent.js.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewDialog.d.ts +12 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewDialog.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewDialog.js +13 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewDialog.js.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewPanel.d.ts +8 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewPanel.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewPanel.js +16 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewPanel.js.map +1 -0
- package/dist/react/src/components/DiffViewer/HunkHeader.d.ts +5 -0
- package/dist/react/src/components/DiffViewer/HunkHeader.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/HunkHeader.js +5 -0
- package/dist/react/src/components/DiffViewer/HunkHeader.js.map +1 -0
- package/dist/react/src/components/DiffViewer/InlineCommentSlot.d.ts +18 -0
- package/dist/react/src/components/DiffViewer/InlineCommentSlot.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/InlineCommentSlot.js +13 -0
- package/dist/react/src/components/DiffViewer/InlineCommentSlot.js.map +1 -0
- package/dist/react/src/components/DiffViewer/MarkdownCode.d.ts +9 -0
- package/dist/react/src/components/DiffViewer/MarkdownCode.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/MarkdownCode.js +24 -0
- package/dist/react/src/components/DiffViewer/MarkdownCode.js.map +1 -0
- package/dist/react/src/components/DiffViewer/MermaidBlock.d.ts +4 -0
- package/dist/react/src/components/DiffViewer/MermaidBlock.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/MermaidBlock.js +51 -0
- package/dist/react/src/components/DiffViewer/MermaidBlock.js.map +1 -0
- package/dist/react/src/components/DiffViewer/RenderedImageView.d.ts +8 -0
- package/dist/react/src/components/DiffViewer/RenderedImageView.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/RenderedImageView.js +46 -0
- package/dist/react/src/components/DiffViewer/RenderedImageView.js.map +1 -0
- package/dist/react/src/components/DiffViewer/RenderedMarkdownView.d.ts +16 -0
- package/dist/react/src/components/DiffViewer/RenderedMarkdownView.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/RenderedMarkdownView.js +324 -0
- package/dist/react/src/components/DiffViewer/RenderedMarkdownView.js.map +1 -0
- package/dist/react/src/components/DiffViewer/RenderedSvgView.d.ts +7 -0
- package/dist/react/src/components/DiffViewer/RenderedSvgView.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/RenderedSvgView.js +21 -0
- package/dist/react/src/components/DiffViewer/RenderedSvgView.js.map +1 -0
- package/dist/react/src/components/DiffViewer/SplitView.d.ts +23 -0
- package/dist/react/src/components/DiffViewer/SplitView.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/SplitView.js +137 -0
- package/dist/react/src/components/DiffViewer/SplitView.js.map +1 -0
- package/dist/react/src/components/DiffViewer/SyntaxLine.d.ts +49 -0
- package/dist/react/src/components/DiffViewer/SyntaxLine.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/SyntaxLine.js +73 -0
- package/dist/react/src/components/DiffViewer/SyntaxLine.js.map +1 -0
- package/dist/react/src/components/DiffViewer/UnifiedView.d.ts +23 -0
- package/dist/react/src/components/DiffViewer/UnifiedView.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/UnifiedView.js +96 -0
- package/dist/react/src/components/DiffViewer/UnifiedView.js.map +1 -0
- package/dist/react/src/components/DiffViewer/diff-utils.d.ts +31 -0
- package/dist/react/src/components/DiffViewer/diff-utils.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/diff-utils.js +134 -0
- package/dist/react/src/components/DiffViewer/diff-utils.js.map +1 -0
- package/dist/react/src/components/DiffViewer/useDragSelection.d.ts +25 -0
- package/dist/react/src/components/DiffViewer/useDragSelection.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/useDragSelection.js +210 -0
- package/dist/react/src/components/DiffViewer/useDragSelection.js.map +1 -0
- package/dist/react/src/components/DiffViewer/useExpandContext.d.ts +15 -0
- package/dist/react/src/components/DiffViewer/useExpandContext.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/useExpandContext.js +209 -0
- package/dist/react/src/components/DiffViewer/useExpandContext.js.map +1 -0
- package/dist/react/src/components/FileTree.d.ts +2 -0
- package/dist/react/src/components/FileTree.d.ts.map +1 -0
- package/dist/react/src/components/FileTree.js +93 -0
- package/dist/react/src/components/FileTree.js.map +1 -0
- package/dist/react/src/components/FileTreeEntry.d.ts +13 -0
- package/dist/react/src/components/FileTreeEntry.d.ts.map +1 -0
- package/dist/react/src/components/FileTreeEntry.js +21 -0
- package/dist/react/src/components/FileTreeEntry.js.map +1 -0
- package/dist/react/src/components/FileTreeToggle.d.ts +15 -0
- package/dist/react/src/components/FileTreeToggle.d.ts.map +1 -0
- package/dist/react/src/components/FileTreeToggle.js +16 -0
- package/dist/react/src/components/FileTreeToggle.js.map +1 -0
- package/dist/react/src/components/GuideRouteHud.d.ts +10 -0
- package/dist/react/src/components/GuideRouteHud.d.ts.map +1 -0
- package/dist/react/src/components/GuideRouteHud.js +43 -0
- package/dist/react/src/components/GuideRouteHud.js.map +1 -0
- package/dist/react/src/components/GuideRouteMap.d.ts +20 -0
- package/dist/react/src/components/GuideRouteMap.d.ts.map +1 -0
- package/dist/react/src/components/GuideRouteMap.js +58 -0
- package/dist/react/src/components/GuideRouteMap.js.map +1 -0
- package/dist/react/src/components/GuideStation.d.ts +28 -0
- package/dist/react/src/components/GuideStation.d.ts.map +1 -0
- package/dist/react/src/components/GuideStation.js +24 -0
- package/dist/react/src/components/GuideStation.js.map +1 -0
- package/dist/react/src/components/HintOverlay.d.ts +13 -0
- package/dist/react/src/components/HintOverlay.d.ts.map +1 -0
- package/dist/react/src/components/HintOverlay.js +27 -0
- package/dist/react/src/components/HintOverlay.js.map +1 -0
- package/dist/react/src/components/KeyboardNavigationManager.d.ts +2 -0
- package/dist/react/src/components/KeyboardNavigationManager.d.ts.map +1 -0
- package/dist/react/src/components/KeyboardNavigationManager.js +8 -0
- package/dist/react/src/components/KeyboardNavigationManager.js.map +1 -0
- package/dist/react/src/components/Layout.d.ts +2 -0
- package/dist/react/src/components/Layout.d.ts.map +1 -0
- package/dist/react/src/components/Layout.js +63 -0
- package/dist/react/src/components/Layout.js.map +1 -0
- package/dist/react/src/components/ReviewProgress.d.ts +2 -0
- package/dist/react/src/components/ReviewProgress.d.ts.map +1 -0
- package/dist/react/src/components/ReviewProgress.js +25 -0
- package/dist/react/src/components/ReviewProgress.js.map +1 -0
- package/dist/react/src/components/Toolbar.d.ts +6 -0
- package/dist/react/src/components/Toolbar.d.ts.map +1 -0
- package/dist/react/src/components/Toolbar.js +61 -0
- package/dist/react/src/components/Toolbar.js.map +1 -0
- package/dist/react/src/components/TruncatedPath.d.ts +7 -0
- package/dist/react/src/components/TruncatedPath.d.ts.map +1 -0
- package/dist/react/src/components/TruncatedPath.js +15 -0
- package/dist/react/src/components/TruncatedPath.js.map +1 -0
- package/dist/react/src/components/ui/badge.d.ts +10 -0
- package/dist/react/src/components/ui/badge.d.ts.map +1 -0
- package/dist/react/src/components/ui/badge.js +21 -0
- package/dist/react/src/components/ui/badge.js.map +1 -0
- package/dist/react/src/components/ui/button.d.ts +11 -0
- package/dist/react/src/components/ui/button.d.ts.map +1 -0
- package/dist/react/src/components/ui/button.js +32 -0
- package/dist/react/src/components/ui/button.js.map +1 -0
- package/dist/react/src/components/ui/dialog.d.ts +12 -0
- package/dist/react/src/components/ui/dialog.d.ts.map +1 -0
- package/dist/react/src/components/ui/dialog.js +23 -0
- package/dist/react/src/components/ui/dialog.js.map +1 -0
- package/dist/react/src/components/ui/input.d.ts +4 -0
- package/dist/react/src/components/ui/input.d.ts.map +1 -0
- package/dist/react/src/components/ui/input.js +9 -0
- package/dist/react/src/components/ui/input.js.map +1 -0
- package/dist/react/src/components/ui/separator.d.ts +6 -0
- package/dist/react/src/components/ui/separator.d.ts.map +1 -0
- package/dist/react/src/components/ui/separator.js +8 -0
- package/dist/react/src/components/ui/separator.js.map +1 -0
- package/dist/react/src/components/ui/table.d.ts +11 -0
- package/dist/react/src/components/ui/table.d.ts.map +1 -0
- package/dist/react/src/components/ui/table.js +21 -0
- package/dist/react/src/components/ui/table.js.map +1 -0
- package/dist/react/src/components/ui/textarea.d.ts +4 -0
- package/dist/react/src/components/ui/textarea.d.ts.map +1 -0
- package/dist/react/src/components/ui/textarea.js +9 -0
- package/dist/react/src/components/ui/textarea.js.map +1 -0
- package/dist/react/src/components/ui/toggle-group.d.ts +22 -0
- package/dist/react/src/components/ui/toggle-group.d.ts.map +1 -0
- package/dist/react/src/components/ui/toggle-group.js +48 -0
- package/dist/react/src/components/ui/toggle-group.js.map +1 -0
- package/dist/react/src/components/ui/tooltip.d.ts +16 -0
- package/dist/react/src/components/ui/tooltip.d.ts.map +1 -0
- package/dist/react/src/components/ui/tooltip.js +21 -0
- package/dist/react/src/components/ui/tooltip.js.map +1 -0
- package/dist/react/src/context/ConfigContext.d.ts +26 -0
- package/dist/react/src/context/ConfigContext.d.ts.map +1 -0
- package/dist/react/src/context/ConfigContext.js +150 -0
- package/dist/react/src/context/ConfigContext.js.map +1 -0
- package/dist/react/src/context/DiffNavigationContext.d.ts +16 -0
- package/dist/react/src/context/DiffNavigationContext.d.ts.map +1 -0
- package/dist/react/src/context/DiffNavigationContext.js +79 -0
- package/dist/react/src/context/DiffNavigationContext.js.map +1 -0
- package/dist/react/src/context/GuideContext.d.ts +28 -0
- package/dist/react/src/context/GuideContext.d.ts.map +1 -0
- package/dist/react/src/context/GuideContext.js +64 -0
- package/dist/react/src/context/GuideContext.js.map +1 -0
- package/dist/react/src/context/ReviewAdapterContext.d.ts +9 -0
- package/dist/react/src/context/ReviewAdapterContext.d.ts.map +1 -0
- package/dist/react/src/context/ReviewAdapterContext.js +10 -0
- package/dist/react/src/context/ReviewAdapterContext.js.map +1 -0
- package/dist/react/src/context/ReviewContext.d.ts +60 -0
- package/dist/react/src/context/ReviewContext.d.ts.map +1 -0
- package/dist/react/src/context/ReviewContext.js +233 -0
- package/dist/react/src/context/ReviewContext.js.map +1 -0
- package/dist/react/src/hooks/useDiffNavigation.d.ts +4 -0
- package/dist/react/src/hooks/useDiffNavigation.d.ts.map +1 -0
- package/dist/react/src/hooks/useDiffNavigation.js +5 -0
- package/dist/react/src/hooks/useDiffNavigation.js.map +1 -0
- package/dist/react/src/hooks/useEmojiAutocomplete.d.ts +24 -0
- package/dist/react/src/hooks/useEmojiAutocomplete.d.ts.map +1 -0
- package/dist/react/src/hooks/useEmojiAutocomplete.js +175 -0
- package/dist/react/src/hooks/useEmojiAutocomplete.js.map +1 -0
- package/dist/react/src/hooks/useKeyboardNavigation.d.ts +15 -0
- package/dist/react/src/hooks/useKeyboardNavigation.d.ts.map +1 -0
- package/dist/react/src/hooks/useKeyboardNavigation.js +227 -0
- package/dist/react/src/hooks/useKeyboardNavigation.js.map +1 -0
- package/dist/react/src/hooks/useReviewBridge.d.ts +15 -0
- package/dist/react/src/hooks/useReviewBridge.d.ts.map +1 -0
- package/dist/react/src/hooks/useReviewBridge.js +43 -0
- package/dist/react/src/hooks/useReviewBridge.js.map +1 -0
- package/dist/react/src/hooks/useReviewState.d.ts +16 -0
- package/dist/react/src/hooks/useReviewState.d.ts.map +1 -0
- package/dist/react/src/hooks/useReviewState.js +101 -0
- package/dist/react/src/hooks/useReviewState.js.map +1 -0
- package/dist/react/src/index.d.ts +25 -0
- package/dist/react/src/index.d.ts.map +1 -0
- package/dist/react/src/index.js +22 -0
- package/dist/react/src/index.js.map +1 -0
- package/dist/react/src/lib/utils.d.ts +3 -0
- package/dist/react/src/lib/utils.d.ts.map +1 -0
- package/dist/react/src/lib/utils.js +6 -0
- package/dist/react/src/lib/utils.js.map +1 -0
- package/dist/react/src/utils/category-utils.d.ts +17 -0
- package/dist/react/src/utils/category-utils.d.ts.map +1 -0
- package/dist/react/src/utils/category-utils.js +23 -0
- package/dist/react/src/utils/category-utils.js.map +1 -0
- package/dist/react/src/utils/comment-anchors.d.ts +4 -0
- package/dist/react/src/utils/comment-anchors.d.ts.map +1 -0
- package/dist/react/src/utils/comment-anchors.js +17 -0
- package/dist/react/src/utils/comment-anchors.js.map +1 -0
- package/dist/react/src/utils/diff-styles.d.ts +12 -0
- package/dist/react/src/utils/diff-styles.d.ts.map +1 -0
- package/dist/react/src/utils/diff-styles.js +46 -0
- package/dist/react/src/utils/diff-styles.js.map +1 -0
- package/dist/react/src/utils/emoji-data.d.ts +8 -0
- package/dist/react/src/utils/emoji-data.d.ts.map +1 -0
- package/dist/react/src/utils/emoji-data.js +43 -0
- package/dist/react/src/utils/emoji-data.js.map +1 -0
- package/dist/react/src/utils/file-type-utils.d.ts +20 -0
- package/dist/react/src/utils/file-type-utils.d.ts.map +1 -0
- package/dist/react/src/utils/file-type-utils.js +110 -0
- package/dist/react/src/utils/file-type-utils.js.map +1 -0
- package/dist/react/src/utils/front-matter.d.ts +14 -0
- package/dist/react/src/utils/front-matter.d.ts.map +1 -0
- package/dist/react/src/utils/front-matter.js +40 -0
- package/dist/react/src/utils/front-matter.js.map +1 -0
- package/dist/react/src/utils/guide-accents.d.ts +46 -0
- package/dist/react/src/utils/guide-accents.d.ts.map +1 -0
- package/dist/react/src/utils/guide-accents.js +100 -0
- package/dist/react/src/utils/guide-accents.js.map +1 -0
- package/dist/react/src/utils/guide-display.d.ts +48 -0
- package/dist/react/src/utils/guide-display.d.ts.map +1 -0
- package/dist/react/src/utils/guide-display.js +75 -0
- package/dist/react/src/utils/guide-display.js.map +1 -0
- package/dist/react/src/utils/image-utils.d.ts +3 -0
- package/dist/react/src/utils/image-utils.d.ts.map +1 -0
- package/dist/react/src/utils/image-utils.js +33 -0
- package/dist/react/src/utils/image-utils.js.map +1 -0
- package/dist/react/src/utils/passive-content.d.ts +9 -0
- package/dist/react/src/utils/passive-content.d.ts.map +1 -0
- package/dist/react/src/utils/passive-content.js +135 -0
- package/dist/react/src/utils/passive-content.js.map +1 -0
- package/dist/react/src/utils/remark-emoji.d.ts +3 -0
- package/dist/react/src/utils/remark-emoji.d.ts.map +1 -0
- package/dist/react/src/utils/remark-emoji.js +38 -0
- package/dist/react/src/utils/remark-emoji.js.map +1 -0
- package/dist/serve/src/args.d.ts +15 -0
- package/dist/serve/src/args.d.ts.map +1 -0
- package/dist/serve/src/args.js +65 -0
- package/dist/serve/src/args.js.map +1 -0
- package/dist/serve/src/cli.d.ts +3 -0
- package/dist/serve/src/cli.d.ts.map +1 -0
- package/dist/serve/src/cli.js +81 -0
- package/dist/serve/src/cli.js.map +1 -0
- package/dist/serve/src/client/adapter.d.ts +25 -0
- package/dist/serve/src/client/adapter.d.ts.map +1 -0
- package/dist/serve/src/client/adapter.js +190 -0
- package/dist/serve/src/client/adapter.js.map +1 -0
- package/dist/serve/src/client/index.d.ts +2 -0
- package/dist/serve/src/client/index.d.ts.map +1 -0
- package/dist/serve/src/client/index.js +135 -0
- package/dist/serve/src/client/index.js.map +1 -0
- package/dist/serve/src/lifecycle.d.ts +27 -0
- package/dist/serve/src/lifecycle.d.ts.map +1 -0
- package/dist/serve/src/lifecycle.js +73 -0
- package/dist/serve/src/lifecycle.js.map +1 -0
- package/dist/serve/src/server.d.ts +34 -0
- package/dist/serve/src/server.d.ts.map +1 -0
- package/dist/serve/src/server.js +430 -0
- package/dist/serve/src/server.js.map +1 -0
- package/dist/serve/src/startup.d.ts +19 -0
- package/dist/serve/src/startup.d.ts.map +1 -0
- package/dist/serve/src/startup.js +117 -0
- package/dist/serve/src/startup.js.map +1 -0
- package/dist/serve/src/validate.d.ts +44 -0
- package/dist/serve/src/validate.d.ts.map +1 -0
- package/dist/serve/src/validate.js +295 -0
- package/dist/serve/src/validate.js.map +1 -0
- package/dist/types/src/index.d.ts +417 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/index.js +5 -0
- package/dist/types/src/index.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
// Eight JSON routes over one ReviewSession, each a thin wrapper over a function
|
|
2
|
+
// core already exports, plus static serving for the client bundle. node:http,
|
|
3
|
+
// no framework.
|
|
4
|
+
//
|
|
5
|
+
// Two properties are load-bearing: every route validates before core runs, and
|
|
6
|
+
// the listener both binds to loopback and refuses requests that name anything
|
|
7
|
+
// else. Binding alone is not enough — a web page can reach a loopback port, and
|
|
8
|
+
// DNS rebinding would make it same-origin. There is no authentication.
|
|
9
|
+
import * as fs from 'node:fs';
|
|
10
|
+
import * as http from 'node:http';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
import { getDiffLoad, getConfigLoad, getResumeLoad, getFileHunks, loadImage, readAttachment, expandContext, submitReviewState, applySuggestionForSession, } from '@self-review/core';
|
|
14
|
+
import { containPath, parseExpandContextBody, parseReviewStateBody, parseSuggestionApplyBody, } from './validate';
|
|
15
|
+
/** `client/` next to this module, which is `dist/client/` once built. */
|
|
16
|
+
export const CLIENT_DIR = fileURLToPath(new URL('./client/', import.meta.url));
|
|
17
|
+
/** Upper bound on a `POST /api/expand-context` body: a path and an integer. */
|
|
18
|
+
export const MAX_EXPAND_CONTEXT_BODY_BYTES = 64 * 1024;
|
|
19
|
+
/** Generous but finite: an unbounded read is a trivial denial of service. */
|
|
20
|
+
export const MAX_REVIEW_BODY_BYTES = 32 * 1024 * 1024;
|
|
21
|
+
const CONTENT_TYPES = {
|
|
22
|
+
'.html': 'text/html; charset=utf-8',
|
|
23
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
24
|
+
'.mjs': 'text/javascript; charset=utf-8',
|
|
25
|
+
'.css': 'text/css; charset=utf-8',
|
|
26
|
+
'.map': 'application/json; charset=utf-8',
|
|
27
|
+
'.json': 'application/json; charset=utf-8',
|
|
28
|
+
'.svg': 'image/svg+xml',
|
|
29
|
+
'.png': 'image/png',
|
|
30
|
+
'.ico': 'image/x-icon',
|
|
31
|
+
'.woff': 'font/woff',
|
|
32
|
+
'.woff2': 'font/woff2',
|
|
33
|
+
'.txt': 'text/plain; charset=utf-8',
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The page renders the diff under review, which is the least trusted input the
|
|
37
|
+
* program handles. Rendered content is sanitized before it becomes elements;
|
|
38
|
+
* this is the second line, for whatever gets past that.
|
|
39
|
+
*
|
|
40
|
+
* Inline styles are allowed because index.html carries a <style> block and
|
|
41
|
+
* bundled libraries inject at runtime; blob: because attachments display
|
|
42
|
+
* through createObjectURL.
|
|
43
|
+
*/
|
|
44
|
+
const CSP = [
|
|
45
|
+
"default-src 'self'",
|
|
46
|
+
"script-src 'self'",
|
|
47
|
+
"style-src 'self' 'unsafe-inline'",
|
|
48
|
+
"img-src 'self' data: blob:",
|
|
49
|
+
"font-src 'self' data:",
|
|
50
|
+
"connect-src 'self'",
|
|
51
|
+
"frame-src 'none'",
|
|
52
|
+
"child-src 'none'",
|
|
53
|
+
"object-src 'none'",
|
|
54
|
+
"base-uri 'none'",
|
|
55
|
+
"form-action 'none'",
|
|
56
|
+
"frame-ancestors 'none'",
|
|
57
|
+
].join('; ');
|
|
58
|
+
const SECURITY_HEADERS = {
|
|
59
|
+
'content-security-policy': CSP,
|
|
60
|
+
'x-content-type-options': 'nosniff',
|
|
61
|
+
'x-frame-options': 'DENY',
|
|
62
|
+
'referrer-policy': 'no-referrer',
|
|
63
|
+
};
|
|
64
|
+
/** A browser may resolve the printed URL either way, or prefer IPv6. */
|
|
65
|
+
const LOOPBACK_HOSTNAMES = new Set(['127.0.0.1', 'localhost', '[::1]']);
|
|
66
|
+
/** Lowercased, with an explicit `:80` dropped so it matches the bare host. */
|
|
67
|
+
function normalizeHost(value) {
|
|
68
|
+
const lowered = value.toLowerCase();
|
|
69
|
+
return lowered.endsWith(':80') ? lowered.slice(0, -3) : lowered;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A rebound request — an attacker's name re-resolved to 127.0.0.1 after the
|
|
73
|
+
* page loads — still carries that name in `Host`, which is what distinguishes
|
|
74
|
+
* it from a real one.
|
|
75
|
+
*
|
|
76
|
+
* The port is deliberately not compared against the bound port: an `ssh -L`
|
|
77
|
+
* forward arrives carrying the forward's port, and refusing that would break
|
|
78
|
+
* the use case this package exists for. It would buy nothing either, since a
|
|
79
|
+
* rebound request fails on the hostname first.
|
|
80
|
+
*
|
|
81
|
+
* A duplicate `Host` is refused, not resolved: Node reads the first, and an
|
|
82
|
+
* intermediary forwarding the last would be reading a different request.
|
|
83
|
+
*/
|
|
84
|
+
function hostIsLoopback(req) {
|
|
85
|
+
const host = req.headers.host;
|
|
86
|
+
if (host === undefined)
|
|
87
|
+
return false;
|
|
88
|
+
let seen = 0;
|
|
89
|
+
for (let i = 0; i < req.rawHeaders.length; i += 2) {
|
|
90
|
+
if (req.rawHeaders[i].toLowerCase() === 'host')
|
|
91
|
+
seen++;
|
|
92
|
+
}
|
|
93
|
+
if (seen !== 1)
|
|
94
|
+
return false;
|
|
95
|
+
// Split the optional port off, keeping an IPv6 literal's brackets.
|
|
96
|
+
const match = /^(\[[^\]]*\]|[^:]*)(?::(\d+))?$/.exec(host);
|
|
97
|
+
if (match === null)
|
|
98
|
+
return false;
|
|
99
|
+
return LOOPBACK_HOSTNAMES.has(match[1].toLowerCase());
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A missing `Origin` is allowed — navigations and curl send none. Rejected is
|
|
103
|
+
* an `Origin` naming a different authority than `Host`, including the `null` a
|
|
104
|
+
* sandboxed frame sends.
|
|
105
|
+
*
|
|
106
|
+
* Comparing against `Host` rather than a loopback allowlist is what survives a
|
|
107
|
+
* port forward while still refusing another local page: a dev server on :3000
|
|
108
|
+
* sends its own origin and this listener's host, and those differ.
|
|
109
|
+
*/
|
|
110
|
+
function originMatchesHost(req) {
|
|
111
|
+
const origin = req.headers.origin;
|
|
112
|
+
if (origin === undefined)
|
|
113
|
+
return true;
|
|
114
|
+
const host = req.headers.host;
|
|
115
|
+
if (host === undefined)
|
|
116
|
+
return false;
|
|
117
|
+
let parsed;
|
|
118
|
+
try {
|
|
119
|
+
parsed = new URL(origin);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
if (parsed.protocol !== 'http:')
|
|
125
|
+
return false;
|
|
126
|
+
// `new URL` parses away userinfo, paths and leading-zero ports, any of which
|
|
127
|
+
// would compare equal to this authority. A browser sends none of them.
|
|
128
|
+
if (origin !== `${parsed.protocol}//${parsed.host}`)
|
|
129
|
+
return false;
|
|
130
|
+
return normalizeHost(parsed.host) === normalizeHost(host);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Set by the browser, unforgeable by page script. A cross-site *GET* — an <img>
|
|
134
|
+
* aimed at this port — carries no `Origin`, so without this it would be served
|
|
135
|
+
* and only the absence of CORS headers would stop the page reading it.
|
|
136
|
+
*
|
|
137
|
+
* Non-browser clients send no such header and are unaffected.
|
|
138
|
+
*/
|
|
139
|
+
function fetchSiteIsSelf(req) {
|
|
140
|
+
const site = req.headers['sec-fetch-site'];
|
|
141
|
+
if (site === undefined)
|
|
142
|
+
return true;
|
|
143
|
+
return site === 'same-origin' || site === 'none';
|
|
144
|
+
}
|
|
145
|
+
function sendJson(res, status, value, headers = {}) {
|
|
146
|
+
res.writeHead(status, {
|
|
147
|
+
'content-type': 'application/json; charset=utf-8',
|
|
148
|
+
'cache-control': 'no-store',
|
|
149
|
+
...SECURITY_HEADERS,
|
|
150
|
+
...headers,
|
|
151
|
+
});
|
|
152
|
+
// `JSON.stringify(undefined)` is undefined; a void core result becomes `null`.
|
|
153
|
+
res.end(JSON.stringify(value ?? null));
|
|
154
|
+
}
|
|
155
|
+
function sendError(res, status, error) {
|
|
156
|
+
// A body that blew the cap is not read further; close the connection rather
|
|
157
|
+
// than let the rest of it be reinterpreted as a next request.
|
|
158
|
+
sendJson(res, status, { error }, status === 413 ? { connection: 'close' } : {});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Contain the `path` parameter under the repository root. Returns it both as
|
|
162
|
+
* sent (core interprets it relative to the repository) and resolved (for a
|
|
163
|
+
* handler reading disk directly), or answers 400 and returns null.
|
|
164
|
+
*/
|
|
165
|
+
function requireContainedPath(ctx) {
|
|
166
|
+
const raw = ctx.url.searchParams.get('path');
|
|
167
|
+
const resolved = raw ? containPath(ctx.repositoryRoot, raw) : null;
|
|
168
|
+
if (raw === null || resolved === null) {
|
|
169
|
+
sendError(ctx.res, 400, 'path must be a file under the repository root');
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
return { raw, resolved };
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The declared length is checked before a byte is read and the running total
|
|
176
|
+
* during it, so a chunked body without a length is capped too.
|
|
177
|
+
*/
|
|
178
|
+
function readJsonBody(req, maxBytes) {
|
|
179
|
+
const contentType = req.headers['content-type'] ?? '';
|
|
180
|
+
if (!contentType.toLowerCase().startsWith('application/json')) {
|
|
181
|
+
return Promise.resolve({
|
|
182
|
+
ok: false,
|
|
183
|
+
status: 415,
|
|
184
|
+
error: 'content-type must be application/json',
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
const declared = Number(req.headers['content-length']);
|
|
188
|
+
if (Number.isFinite(declared) && declared > maxBytes) {
|
|
189
|
+
return Promise.resolve({ ok: false, status: 413, error: 'request body too large' });
|
|
190
|
+
}
|
|
191
|
+
return new Promise(resolve => {
|
|
192
|
+
const chunks = [];
|
|
193
|
+
let received = 0;
|
|
194
|
+
req.on('data', (chunk) => {
|
|
195
|
+
received += chunk.length;
|
|
196
|
+
if (received > maxBytes) {
|
|
197
|
+
chunks.length = 0;
|
|
198
|
+
req.removeAllListeners('data');
|
|
199
|
+
req.removeAllListeners('end');
|
|
200
|
+
resolve({ ok: false, status: 413, error: 'request body too large' });
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
chunks.push(chunk);
|
|
204
|
+
});
|
|
205
|
+
req.on('end', () => {
|
|
206
|
+
try {
|
|
207
|
+
resolve({ ok: true, value: JSON.parse(Buffer.concat(chunks).toString('utf-8')) });
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
resolve({ ok: false, status: 400, error: 'body must be valid JSON' });
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
req.on('error', () => {
|
|
214
|
+
resolve({ ok: false, status: 400, error: 'request body could not be read' });
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
// Each route validates, calls exactly one core function, and sends its result.
|
|
219
|
+
const routes = {
|
|
220
|
+
'GET /api/diff': async ({ res, session }) => {
|
|
221
|
+
// The guide rides with the diff, so the client needs no push channel.
|
|
222
|
+
sendJson(res, 200, getDiffLoad(session));
|
|
223
|
+
},
|
|
224
|
+
'GET /api/config': async ({ res, session }) => {
|
|
225
|
+
sendJson(res, 200, getConfigLoad(session));
|
|
226
|
+
},
|
|
227
|
+
'GET /api/resume': async ({ res, session }) => {
|
|
228
|
+
sendJson(res, 200, getResumeLoad(session));
|
|
229
|
+
},
|
|
230
|
+
'GET /api/file': async (ctx) => {
|
|
231
|
+
const contained = requireContainedPath(ctx);
|
|
232
|
+
if (contained === null)
|
|
233
|
+
return;
|
|
234
|
+
// Diff paths are repository-relative strings; core matches on them as sent.
|
|
235
|
+
sendJson(ctx.res, 200, getFileHunks(ctx.session, contained.raw));
|
|
236
|
+
},
|
|
237
|
+
'GET /api/image': async (ctx) => {
|
|
238
|
+
const contained = requireContainedPath(ctx);
|
|
239
|
+
if (contained === null)
|
|
240
|
+
return;
|
|
241
|
+
// Core resolves against the repository itself, so it gets the raw value.
|
|
242
|
+
sendJson(ctx.res, 200, await loadImage(ctx.session, contained.raw));
|
|
243
|
+
},
|
|
244
|
+
'GET /api/attachment': async (ctx) => {
|
|
245
|
+
// A different namespace from diff paths, and a different root: review.xml
|
|
246
|
+
// records these relative to the output file's directory. Rooting them at
|
|
247
|
+
// the repository 404s every resumed image when -o points elsewhere.
|
|
248
|
+
const assetRoot = ctx.session.outputPathInfo
|
|
249
|
+
? path.dirname(ctx.session.outputPathInfo.resolvedOutputPath)
|
|
250
|
+
: ctx.repositoryRoot;
|
|
251
|
+
const raw = ctx.url.searchParams.get('path');
|
|
252
|
+
const resolved = raw ? containPath(assetRoot, raw) : null;
|
|
253
|
+
if (resolved === null) {
|
|
254
|
+
sendError(ctx.res, 400, 'path must be a file under the output directory');
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
// Core reads this path from disk directly, so it gets the contained real path.
|
|
258
|
+
const data = await readAttachment(resolved);
|
|
259
|
+
if (data === null) {
|
|
260
|
+
sendError(ctx.res, 404, 'attachment not found');
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const { res } = ctx;
|
|
264
|
+
res.writeHead(200, {
|
|
265
|
+
'content-type': 'application/octet-stream',
|
|
266
|
+
'cache-control': 'no-store',
|
|
267
|
+
...SECURITY_HEADERS,
|
|
268
|
+
});
|
|
269
|
+
res.end(Buffer.from(data));
|
|
270
|
+
},
|
|
271
|
+
'POST /api/expand-context': async ({ req, res, session, repositoryRoot }) => {
|
|
272
|
+
const body = await readJsonBody(req, MAX_EXPAND_CONTEXT_BODY_BYTES);
|
|
273
|
+
if (!body.ok) {
|
|
274
|
+
sendError(res, body.status, body.error);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const parsed = parseExpandContextBody(body.value);
|
|
278
|
+
if (!parsed.ok) {
|
|
279
|
+
sendError(res, 400, parsed.error);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
// Becomes a git pathspec; contain it, then pass it through as sent.
|
|
283
|
+
if (containPath(repositoryRoot, parsed.value.filePath) === null) {
|
|
284
|
+
sendError(res, 400, 'filePath must be a file under the repository root');
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
sendJson(res, 200, await expandContext(session, parsed.value));
|
|
288
|
+
},
|
|
289
|
+
// The one route that rewrites a file in the reviewed tree. Core refuses
|
|
290
|
+
// unless the anchored lines still match the suggestion's recorded original
|
|
291
|
+
// byte for byte, and resolves the destination itself; the path is contained
|
|
292
|
+
// here so a request cannot even name a file outside the repository.
|
|
293
|
+
'POST /api/apply-suggestion': async ({ req, res, session, repositoryRoot }) => {
|
|
294
|
+
const body = await readJsonBody(req, MAX_EXPAND_CONTEXT_BODY_BYTES);
|
|
295
|
+
if (!body.ok) {
|
|
296
|
+
sendError(res, body.status, body.error);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const parsed = parseSuggestionApplyBody(body.value);
|
|
300
|
+
if (!parsed.ok) {
|
|
301
|
+
sendError(res, 400, parsed.error);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (containPath(repositoryRoot, parsed.value.filePath) === null) {
|
|
305
|
+
sendError(res, 400, 'filePath must be a file under the repository root');
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
sendJson(res, 200, applySuggestionForSession(session, parsed.value));
|
|
309
|
+
},
|
|
310
|
+
'POST /api/review': async ({ req, res, session }) => {
|
|
311
|
+
const body = await readJsonBody(req, MAX_REVIEW_BODY_BYTES);
|
|
312
|
+
if (!body.ok) {
|
|
313
|
+
sendError(res, body.status, body.error);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const parsed = parseReviewStateBody(body.value);
|
|
317
|
+
if (!parsed.ok) {
|
|
318
|
+
sendError(res, 400, parsed.error);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
submitReviewState(session, parsed.value);
|
|
322
|
+
sendJson(res, 200, null);
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
const ROUTE_PATHS = new Set(Object.keys(routes).map(key => key.split(' ')[1]));
|
|
326
|
+
/**
|
|
327
|
+
* `/` is index.html; everything else is contained under the client directory.
|
|
328
|
+
* Anything that is not a regular file under it is a 404.
|
|
329
|
+
*/
|
|
330
|
+
async function serveStatic(res, clientDir, pathname) {
|
|
331
|
+
let decoded;
|
|
332
|
+
try {
|
|
333
|
+
decoded = decodeURIComponent(pathname);
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
sendError(res, 404, 'not found');
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
const relative = decoded === '/' ? 'index.html' : decoded.replace(/^\/+/, '');
|
|
340
|
+
const resolved = containPath(clientDir, relative);
|
|
341
|
+
if (resolved === null) {
|
|
342
|
+
sendError(res, 404, 'not found');
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
let data;
|
|
346
|
+
try {
|
|
347
|
+
const stat = await fs.promises.stat(resolved);
|
|
348
|
+
if (!stat.isFile()) {
|
|
349
|
+
sendError(res, 404, 'not found');
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
data = await fs.promises.readFile(resolved);
|
|
353
|
+
}
|
|
354
|
+
catch {
|
|
355
|
+
sendError(res, 404, 'not found');
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
res.writeHead(200, {
|
|
359
|
+
'content-type': CONTENT_TYPES[path.extname(resolved).toLowerCase()] ?? 'application/octet-stream',
|
|
360
|
+
'content-length': data.length,
|
|
361
|
+
...SECURITY_HEADERS,
|
|
362
|
+
});
|
|
363
|
+
res.end(data);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Taking the session explicitly rather than reading module state mirrors the
|
|
367
|
+
* core handlers and lets a test drive this without a repository. Not yet
|
|
368
|
+
* listening: bind it with `listenLoopback`.
|
|
369
|
+
*/
|
|
370
|
+
export function createReviewServer(options) {
|
|
371
|
+
const { session, repositoryRoot, clientDir = CLIENT_DIR } = options;
|
|
372
|
+
return http.createServer(async (req, res) => {
|
|
373
|
+
const method = req.method ?? 'GET';
|
|
374
|
+
let url;
|
|
375
|
+
try {
|
|
376
|
+
url = new URL(req.url ?? '/', 'http://localhost');
|
|
377
|
+
}
|
|
378
|
+
catch {
|
|
379
|
+
sendError(res, 400, 'malformed request URL');
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
// Before anything is routed: this listener answers only to itself.
|
|
383
|
+
if (!hostIsLoopback(req) || !originMatchesHost(req) || !fetchSiteIsSelf(req)) {
|
|
384
|
+
sendError(res, 403, 'forbidden');
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
try {
|
|
388
|
+
const handler = routes[`${method} ${url.pathname}`];
|
|
389
|
+
if (handler) {
|
|
390
|
+
await handler({ req, res, url, session, repositoryRoot });
|
|
391
|
+
}
|
|
392
|
+
else if (ROUTE_PATHS.has(url.pathname)) {
|
|
393
|
+
sendError(res, 405, 'method not allowed');
|
|
394
|
+
}
|
|
395
|
+
else if (url.pathname.startsWith('/api/')) {
|
|
396
|
+
sendError(res, 404, 'not found');
|
|
397
|
+
}
|
|
398
|
+
else if (method === 'GET') {
|
|
399
|
+
await serveStatic(res, clientDir, url.pathname);
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
sendError(res, 404, 'not found');
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
catch (error) {
|
|
406
|
+
console.error(`[serve] ${method} ${url.pathname} failed:`, error);
|
|
407
|
+
if (!res.headersSent) {
|
|
408
|
+
sendError(res, 500, 'internal error');
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
res.end();
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* The address is fixed here, not left to the caller: never `0.0.0.0`, never the
|
|
418
|
+
* default. Port 0 asks the OS for an ephemeral one.
|
|
419
|
+
*/
|
|
420
|
+
export function listenLoopback(server, port = 0) {
|
|
421
|
+
return new Promise((resolve, reject) => {
|
|
422
|
+
server.once('error', reject);
|
|
423
|
+
server.listen(port, '127.0.0.1', () => {
|
|
424
|
+
server.off('error', reject);
|
|
425
|
+
const address = server.address();
|
|
426
|
+
resolve({ port: address.port, url: `http://127.0.0.1:${address.port}/` });
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/server.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,8EAA8E;AAC9E,gBAAgB;AAChB,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,gFAAgF;AAChF,uEAAuE;AAEvE,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,WAA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OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE;YACpC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAiB,CAAC;YAChD,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,oBAAoB,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReviewSession } from '@self-review/core';
|
|
2
|
+
import type { ServeArgs } from './args';
|
|
3
|
+
export interface ServeStartup {
|
|
4
|
+
/** The resolved session, complete: diff, guide, config and resume state. */
|
|
5
|
+
session: ReviewSession;
|
|
6
|
+
/**
|
|
7
|
+
* Root every request-supplied path is contained under: the same value core
|
|
8
|
+
* resolves against, since containment guarantees nothing unless they agree.
|
|
9
|
+
*/
|
|
10
|
+
repositoryRoot: string;
|
|
11
|
+
/** Absolute output path, fixed for the lifetime of the process. */
|
|
12
|
+
outputPath: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the session to serve. Throws when there is nothing to review or the
|
|
16
|
+
* resume file cannot be read; the caller reports and exits.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveSession(args: ServeArgs): Promise<ServeStartup>;
|
|
19
|
+
//# sourceMappingURL=startup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup.d.ts","sourceRoot":"","sources":["../../../src/startup.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAA8B,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,OAAO,EAAE,aAAa,CAAC;IACvB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;CACpB;AA6CD;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAkF3E"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Resolve one review session the way the desktop does. Each phase below cites
|
|
2
|
+
// the phase of `initializeApp` (src/main/main.ts) it mirrors.
|
|
3
|
+
//
|
|
4
|
+
// Two orderings are load-bearing: everything resolves before the caller opens
|
|
5
|
+
// the listener, so no request races a half-built session; and the guide lands
|
|
6
|
+
// on the session during startup, since `GET /api/diff` answers from there.
|
|
7
|
+
//
|
|
8
|
+
// The desktop's large-payload prompt and directory picker are native dialogs
|
|
9
|
+
// with no browser equivalent, so the first becomes automatic and the second
|
|
10
|
+
// becomes a startup error.
|
|
11
|
+
import { resolve } from 'node:path';
|
|
12
|
+
import { applyStagedUntrackedDefault, checkWritability, computePayloadStats, countTotalLines, createIgnoreFilter, createReviewSession, determineMode, loadConfig, loadGitDiffWithUntracked, loadGuide, normalizeGitDiffArgs, parseReviewXml, scanDirectory, scanFile, } from '@self-review/core';
|
|
13
|
+
/**
|
|
14
|
+
* Mirrors main.ts phase 4. Welcome mode diverges: there is no directory picker
|
|
15
|
+
* in a browser, so refusing beats serving an interface whose controls are dead.
|
|
16
|
+
*/
|
|
17
|
+
async function loadDiffForMode(gitDiffArgs, config) {
|
|
18
|
+
const mode = determineMode(gitDiffArgs);
|
|
19
|
+
console.error(`[serve] Startup mode: ${mode}`);
|
|
20
|
+
if (mode === 'git') {
|
|
21
|
+
const { files, repository } = await loadGitDiffWithUntracked(gitDiffArgs);
|
|
22
|
+
const shouldKeep = createIgnoreFilter(config.ignore);
|
|
23
|
+
return {
|
|
24
|
+
files: files.filter(f => shouldKeep(f.newPath || f.oldPath)),
|
|
25
|
+
source: { type: 'git', gitDiffArgs: gitDiffArgs.join(' '), repository },
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (mode === 'file') {
|
|
29
|
+
const fileArg = gitDiffArgs.find(a => a !== '--' && !a.startsWith('-'));
|
|
30
|
+
const sourcePath = resolve(process.cwd(), fileArg);
|
|
31
|
+
return { files: await scanFile(sourcePath), source: { type: 'file', sourcePath } };
|
|
32
|
+
}
|
|
33
|
+
if (mode === 'directory') {
|
|
34
|
+
const dirArg = gitDiffArgs.find(a => a !== '--' && !a.startsWith('-'));
|
|
35
|
+
const sourcePath = resolve(process.cwd(), dirArg);
|
|
36
|
+
return {
|
|
37
|
+
files: await scanDirectory(sourcePath, config.ignore),
|
|
38
|
+
source: { type: 'directory', sourcePath },
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
throw new Error('Nothing to review: this is not a git repository and no path was given. ' +
|
|
42
|
+
'Run self-review-serve inside a git repository, or pass a directory or file to review.');
|
|
43
|
+
}
|
|
44
|
+
/** The root core resolves a diff path against — see `ServeStartup.repositoryRoot`. */
|
|
45
|
+
function containmentRoot(payload) {
|
|
46
|
+
return payload.source.type === 'git' ? payload.source.repository : process.cwd();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolve the session to serve. Throws when there is nothing to review or the
|
|
50
|
+
* resume file cannot be read; the caller reports and exits.
|
|
51
|
+
*/
|
|
52
|
+
export async function resolveSession(args) {
|
|
53
|
+
// Phase 2 (main.ts:163) — configuration and the output path. Fixed here
|
|
54
|
+
// and never again: no route changes it.
|
|
55
|
+
let config = loadConfig();
|
|
56
|
+
const outputPath = resolve(process.cwd(), args.outputPath ?? config.outputFile);
|
|
57
|
+
// The desktop offers a save dialog out of this; the browser has no such
|
|
58
|
+
// control, so a reviewer would have no exit. Fail before the work, not after.
|
|
59
|
+
if (!checkWritability(outputPath)) {
|
|
60
|
+
throw new Error(`Output path is not writable: ${outputPath}. ` +
|
|
61
|
+
'Pass a writable path with --output, or set output-file in .self-review.yaml.');
|
|
62
|
+
}
|
|
63
|
+
console.error(`[serve] Output path: ${outputPath}`);
|
|
64
|
+
// Phase 3 (main.ts:169) — git diff arguments, normalized so a path can
|
|
65
|
+
// never be read as a revision, then the staged/untracked default.
|
|
66
|
+
let gitDiffArgs = args.gitDiffArgs;
|
|
67
|
+
if (gitDiffArgs.length === 0 && config.defaultDiffArgs) {
|
|
68
|
+
gitDiffArgs = config.defaultDiffArgs.split(' ').filter(a => a.length > 0);
|
|
69
|
+
}
|
|
70
|
+
gitDiffArgs = normalizeGitDiffArgs(gitDiffArgs);
|
|
71
|
+
config = applyStagedUntrackedDefault(config, gitDiffArgs);
|
|
72
|
+
// Phase 4 (main.ts:189) — what to review.
|
|
73
|
+
const diffData = await loadDiffForMode(gitDiffArgs, config);
|
|
74
|
+
console.error(`[serve] Loaded ${diffData.files.length} files`);
|
|
75
|
+
// Phase 4b (main.ts:264) — large payload. The desktop asks; there is
|
|
76
|
+
// nobody to ask before the browser connects, so the threshold simply
|
|
77
|
+
// turns on lazy per-file loading (GET /api/file) and says so.
|
|
78
|
+
const stats = computePayloadStats(diffData.files.length, countTotalLines(diffData.files), config);
|
|
79
|
+
if (stats.exceedsAny) {
|
|
80
|
+
console.error(`[serve] Large payload: ${stats.fileCount} files, ${stats.totalLines} lines ` +
|
|
81
|
+
`(thresholds ${config.maxFiles} files, ${config.maxTotalLines} lines) — ` +
|
|
82
|
+
'serving file contents on demand');
|
|
83
|
+
diffData.isLargePayload = true;
|
|
84
|
+
}
|
|
85
|
+
// Phase 5 (main.ts:295) — resume a prior review.
|
|
86
|
+
const session = createReviewSession();
|
|
87
|
+
if (args.resumeFrom) {
|
|
88
|
+
const resumePath = resolve(process.cwd(), args.resumeFrom);
|
|
89
|
+
let parsed;
|
|
90
|
+
try {
|
|
91
|
+
parsed = parseReviewXml(resumePath);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
throw new Error(`Could not read the resume file ${resumePath}: ` +
|
|
95
|
+
(error instanceof Error ? error.message : String(error)));
|
|
96
|
+
}
|
|
97
|
+
session.resumeComments = parsed.comments;
|
|
98
|
+
session.resumeViewedFiles = parsed.viewedFiles;
|
|
99
|
+
console.error(`[serve] Resumed ${parsed.comments.length} comments and ` +
|
|
100
|
+
`${parsed.viewedFiles.length} viewed files from ${resumePath}`);
|
|
101
|
+
}
|
|
102
|
+
// Phase 5b (main.ts:337) — the walkthrough guide sidecar, discovered next
|
|
103
|
+
// to the output path. Tolerant by contract: loadGuide never throws.
|
|
104
|
+
const guideData = await loadGuide(outputPath, config, diffData.files.map(f => f.newPath || f.oldPath));
|
|
105
|
+
if (guideData) {
|
|
106
|
+
console.error(`[serve] Walkthrough guide loaded: ${guideData.groups.length} groups`);
|
|
107
|
+
}
|
|
108
|
+
// Phase 6 (main.ts:350) — assemble. Everything the routes read is on the
|
|
109
|
+
// session before the caller opens the listener.
|
|
110
|
+
session.diffData = diffData;
|
|
111
|
+
session.guideData = guideData;
|
|
112
|
+
session.config = config;
|
|
113
|
+
// Always writable: startup refused above if it was not.
|
|
114
|
+
session.outputPathInfo = { resolvedOutputPath: outputPath, outputPathWritable: true };
|
|
115
|
+
return { session, repositoryRoot: containmentRoot(diffData), outputPath };
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=startup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup.js","sourceRoot":"","sources":["../../../src/startup.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8DAA8D;AAC9D,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAC3E,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,2BAA2B;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,U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,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ExpandContextRequest, ReviewState, SuggestionApplyRequest } from '@self-review/core';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve `candidate` under `root`, or null if it escapes.
|
|
4
|
+
*
|
|
5
|
+
* Never decode here: callers pass a value `searchParams` already decoded once,
|
|
6
|
+
* and decoding again turns `%2E%2E%2F` inside a filename into a real traversal.
|
|
7
|
+
*/
|
|
8
|
+
export declare function containPath(root: string, candidate: string): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Reaches git as `-U${contextLines}`, so it must be bounded. Matches
|
|
11
|
+
* `MAX_CONTEXT` in useExpandContext.ts; keep the two in step.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MAX_CONTEXT_LINES = 99999;
|
|
14
|
+
export type ParseResult<T> = {
|
|
15
|
+
ok: true;
|
|
16
|
+
value: T;
|
|
17
|
+
} | {
|
|
18
|
+
ok: false;
|
|
19
|
+
error: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Accepts exactly `{ filePath, contextLines }`. Unknown keys are rejected, not
|
|
23
|
+
* ignored. The route contains `filePath` with `containPath` before git sees it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseExpandContextBody(body: unknown): ParseResult<ExpandContextRequest>;
|
|
26
|
+
/**
|
|
27
|
+
* Validate the body of `POST /api/apply-suggestion`.
|
|
28
|
+
*
|
|
29
|
+
* This is the one route that rewrites a file in the reviewed tree, so the shape
|
|
30
|
+
* is checked exactly rather than deferred. Core refuses anything whose anchored
|
|
31
|
+
* lines do not still match `originalCode` byte for byte, but it should never be
|
|
32
|
+
* asked a question this malformed in the first place.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseSuggestionApplyBody(body: unknown): ParseResult<SuggestionApplyRequest>;
|
|
35
|
+
/**
|
|
36
|
+
* Accepts exactly `{ timestamp, source, files }`. Remote provenance is never
|
|
37
|
+
* taken from the client; the process injects it after submission.
|
|
38
|
+
*
|
|
39
|
+
* Structural only — the XSD checks nested fields at serialization time. The
|
|
40
|
+
* exception is `id`, checked below, because the serializer turns an id into a
|
|
41
|
+
* file name *before* it validates anything.
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseReviewStateBody(body: unknown): ParseResult<ReviewState>;
|
|
44
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/validate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAqBnG;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoB1E;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAExC,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAQnF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CAAC,oBAAoB,CAAC,CA6BvF;AAMD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CAAC,sBAAsB,CAAC,CAqD3F;AAID;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CAAC,WAAW,CAAC,CA6B5E"}
|