@self-review/serve 1.45.0 → 2.0.3
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 +84 -17
- package/dist/cli.js +209 -196
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-CRvWpEsk.js +1 -0
- package/dist/client/assets/{arc-LxCcHggQ.js → arc-PsXBAWZS.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-C3DgmaC3.js +36 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-BUrTsHao.js +129 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-CpZNs6lz.js +38 -0
- package/dist/client/assets/channel-mzvzhynH.js +1 -0
- package/dist/client/assets/{chunk-QZHKN3VN-GT04-vw7.js → chunk-2Q5K7J3B-BcKcR0LE.js} +1 -1
- package/dist/client/assets/{chunk-FMBD7UC4-tB9OepVI.js → chunk-5VM5RSS4-C7oHjssV.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-BlPczT9-.js +1 -0
- package/dist/client/assets/chunk-IMKFNOWR-JWhBhxWO.js +231 -0
- package/dist/client/assets/{chunk-4BX2VUAB-D2GfUqwd.js → chunk-JWPE2WC7-BHqPUvha.js} +1 -1
- package/dist/client/assets/chunk-POPQ4Y6H-F7oDRNF5.js +1 -0
- package/dist/client/assets/chunk-SVP7TREG-BXZpN96Q.js +88 -0
- package/dist/client/assets/chunk-TICWLB2K-DNvFXi10.js +206 -0
- package/dist/client/assets/{chunk-55IACEB6-C68L7s0h.js → chunk-XXDRQBXY-DOvXkBHK.js} +1 -1
- package/dist/client/assets/classDiagram-ZZMXUADV-BAE1ijM-.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-BAE1ijM-.js +1 -0
- package/dist/client/assets/{cose-bilkent-S5V4N54A-Ds41oEbD.js → cose-bilkent-JH36ORCC-DPJK_EQL.js} +1 -1
- package/dist/client/assets/cynefin-OW5HDTMX-JBAmnTQp.js +166 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CsYygsrr.js +62 -0
- package/dist/client/assets/cytoscape.esm-BB4DxJjf.js +321 -0
- package/dist/client/assets/dagre-GXQ25YYZ-Dbz4M33p.js +4 -0
- package/dist/client/assets/diagram-S7CK7UJ4-Biv-Q_jb.js +30 -0
- package/dist/client/assets/diagram-UQ7AKVKN-JRvoicym.js +41 -0
- package/dist/client/assets/diagram-VSXAHHWV-VAXOLPk0.js +3 -0
- package/dist/client/assets/diagram-VX7I27RA-DRmE-ol9.js +24 -0
- package/dist/client/assets/diagram-Z3DM3KII-CavqQl_8.js +24 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-70cdWXxf.js +1 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-Ha04LW0x.js +99 -0
- package/dist/client/assets/flowDiagram-HODETNUW-BRLi1S7q.js +168 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-BfBVCQ3A.js +292 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-D-GiQOxC.js +106 -0
- package/dist/client/assets/index-hcoT-WH0.css +1 -0
- package/dist/client/assets/index-vUb9LsiF.js +285 -0
- package/dist/client/assets/infoDiagram-27XIBGKW-KEMBoX9p.js +2 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CBS0T3w-.js +70 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-AN4puIAJ.js +139 -0
- package/dist/client/assets/{kanban-definition-3W4ZIXB7-D-BINTOt.js → kanban-definition-UXKFOSKX-BWQivApD.js} +8 -8
- package/dist/client/assets/katex-HP8lGamR.js +257 -0
- package/dist/client/assets/layout-B7etliRi.js +1 -0
- package/dist/client/assets/{linear-CNmY37sq.js → linear-DYVJ9r-o.js} +1 -1
- package/dist/client/assets/mermaid.core-B9m3791z.js +310 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BwhaRhOg.js +96 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-B6zVpKjE.js +1 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-DGmD4H1L.js +39 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-CrKpGbBm.js +7 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-DLcnTQsv.js +1 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-bqG-UOfq.js +84 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-DGRQqw-s.js +40 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-CW-ivDp5.js +162 -0
- package/dist/client/assets/sizeCapture-INFHLROL-BbHjPnUF.js +1 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-BproWKBe.js +1 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-Ck8yo6ic.js +1 -0
- package/dist/client/assets/swimlanes-42K2YHIH-OG2jZQn8.js +1 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-CgYw65ZN.js +8 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-DQeIsWHU.js +120 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CzLpoCxP.js +34 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-Bga8iF2e.js +78 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-BMPq9UWm.js +7 -0
- package/dist/client/index.html +2 -2
- package/package.json +3 -3
- package/dist/client/assets/_basePickBy-DzL66huQ.js +0 -1
- package/dist/client/assets/_baseUniq-D_kA9hnK.js +0 -1
- package/dist/client/assets/architectureDiagram-VXUJARFQ-BmSW2FCh.js +0 -36
- package/dist/client/assets/blockDiagram-VD42YOAC-Duz6oS5b.js +0 -122
- package/dist/client/assets/c4Diagram-YG6GDRKO-Bv4P72yB.js +0 -10
- package/dist/client/assets/channel-ydExFSqY.js +0 -1
- package/dist/client/assets/chunk-B4BG7PRW-BtVwfswM.js +0 -165
- package/dist/client/assets/chunk-DI55MBZ5-BDdO91wt.js +0 -220
- package/dist/client/assets/chunk-QN33PNHL-HjKgp1PB.js +0 -1
- package/dist/client/assets/chunk-TZMSLE5B-DpxXSXMp.js +0 -1
- package/dist/client/assets/classDiagram-2ON5EDUG-Dg8dmmRD.js +0 -1
- package/dist/client/assets/classDiagram-v2-WZHVMYZB-Dg8dmmRD.js +0 -1
- package/dist/client/assets/clone-Bq6xpRgi.js +0 -1
- package/dist/client/assets/cytoscape.esm-5J0xJHOV.js +0 -321
- package/dist/client/assets/dagre-6UL2VRFP-DZiEousR.js +0 -4
- package/dist/client/assets/diagram-PSM6KHXK-0_alnUMs.js +0 -24
- package/dist/client/assets/diagram-QEK2KX5R-KFaKVdU8.js +0 -43
- package/dist/client/assets/diagram-S2PKOQOG-C2Dy10VG.js +0 -24
- package/dist/client/assets/erDiagram-Q2GNP2WA-_P7rrcgu.js +0 -60
- package/dist/client/assets/flowDiagram-NV44I4VS-BvC6gSn5.js +0 -162
- package/dist/client/assets/ganttDiagram-JELNMOA3-DjzuVPeB.js +0 -267
- package/dist/client/assets/gitGraphDiagram-V2S2FVAM-B9fPDqqA.js +0 -65
- package/dist/client/assets/graph-BqLQdgDA.js +0 -1
- package/dist/client/assets/index-CAXQd1OO.js +0 -286
- package/dist/client/assets/index-CmSvc3Wo.css +0 -1
- package/dist/client/assets/infoDiagram-HS3SLOUP-DiMCwlkY.js +0 -2
- package/dist/client/assets/journeyDiagram-XKPGCS4Q-Dn5WdzPP.js +0 -139
- package/dist/client/assets/katex-DhXJpUyf.js +0 -261
- package/dist/client/assets/layout-Bo5pDIcD.js +0 -1
- package/dist/client/assets/mermaid.core-DfADLZQ1.js +0 -250
- package/dist/client/assets/mindmap-definition-VGOIOE7T-H5HwEwuX.js +0 -68
- package/dist/client/assets/pieDiagram-ADFJNKIX-RiZa5XQN.js +0 -30
- package/dist/client/assets/quadrantDiagram-AYHSOK5B-CFFX55h2.js +0 -7
- package/dist/client/assets/requirementDiagram-UZGBJVZJ-B6JBcV1I.js +0 -64
- package/dist/client/assets/sankeyDiagram-TZEHDZUN-GZT80dnc.js +0 -10
- package/dist/client/assets/sequenceDiagram-WL72ISMW-CbUqoUma.js +0 -145
- package/dist/client/assets/stateDiagram-FKZM4ZOC-LEb-ZQVV.js +0 -1
- package/dist/client/assets/stateDiagram-v2-4FDKWEC3-BYGHA8iw.js +0 -1
- package/dist/client/assets/timeline-definition-IT6M3QCI-Cm1Kd50N.js +0 -61
- package/dist/client/assets/treemap-GDKQZRPO-CWXk-dEb.js +0 -160
- package/dist/client/assets/xychartDiagram-PRI3JC2R-BUllxp6G.js +0 -7
- package/dist/core/src/apply-suggestion.d.ts +0 -76
- package/dist/core/src/apply-suggestion.d.ts.map +0 -1
- package/dist/core/src/apply-suggestion.js +0 -109
- package/dist/core/src/apply-suggestion.js.map +0 -1
- package/dist/core/src/config.d.ts +0 -3
- package/dist/core/src/config.d.ts.map +0 -1
- package/dist/core/src/config.js +0 -196
- package/dist/core/src/config.js.map +0 -1
- package/dist/core/src/diff-parser.d.ts +0 -3
- package/dist/core/src/diff-parser.d.ts.map +0 -1
- package/dist/core/src/diff-parser.js +0 -236
- package/dist/core/src/diff-parser.js.map +0 -1
- package/dist/core/src/directory-scanner.d.ts +0 -18
- package/dist/core/src/directory-scanner.d.ts.map +0 -1
- package/dist/core/src/directory-scanner.js +0 -99
- package/dist/core/src/directory-scanner.js.map +0 -1
- package/dist/core/src/fetch-comments.d.ts +0 -69
- package/dist/core/src/fetch-comments.d.ts.map +0 -1
- package/dist/core/src/fetch-comments.js +0 -180
- package/dist/core/src/fetch-comments.js.map +0 -1
- package/dist/core/src/file-type-utils.d.ts +0 -16
- package/dist/core/src/file-type-utils.d.ts.map +0 -1
- package/dist/core/src/file-type-utils.js +0 -106
- package/dist/core/src/file-type-utils.js.map +0 -1
- package/dist/core/src/forge-provider.d.ts +0 -123
- package/dist/core/src/forge-provider.d.ts.map +0 -1
- package/dist/core/src/forge-provider.js +0 -68
- package/dist/core/src/forge-provider.js.map +0 -1
- package/dist/core/src/fs-utils.d.ts +0 -7
- package/dist/core/src/fs-utils.d.ts.map +0 -1
- package/dist/core/src/fs-utils.js +0 -20
- package/dist/core/src/fs-utils.js.map +0 -1
- package/dist/core/src/git-diff-args.d.ts +0 -38
- package/dist/core/src/git-diff-args.d.ts.map +0 -1
- package/dist/core/src/git-diff-args.js +0 -170
- package/dist/core/src/git-diff-args.js.map +0 -1
- package/dist/core/src/git-diff-loader.d.ts +0 -14
- package/dist/core/src/git-diff-loader.d.ts.map +0 -1
- package/dist/core/src/git-diff-loader.js +0 -30
- package/dist/core/src/git-diff-loader.js.map +0 -1
- package/dist/core/src/git.d.ts +0 -52
- package/dist/core/src/git.d.ts.map +0 -1
- package/dist/core/src/git.js +0 -191
- package/dist/core/src/git.js.map +0 -1
- package/dist/core/src/github-provider.d.ts +0 -7
- package/dist/core/src/github-provider.d.ts.map +0 -1
- package/dist/core/src/github-provider.js +0 -151
- package/dist/core/src/github-provider.js.map +0 -1
- package/dist/core/src/gitlab-provider.d.ts +0 -10
- package/dist/core/src/gitlab-provider.d.ts.map +0 -1
- package/dist/core/src/gitlab-provider.js +0 -207
- package/dist/core/src/gitlab-provider.js.map +0 -1
- package/dist/core/src/guide-loader.d.ts +0 -23
- package/dist/core/src/guide-loader.d.ts.map +0 -1
- package/dist/core/src/guide-loader.js +0 -95
- package/dist/core/src/guide-loader.js.map +0 -1
- package/dist/core/src/guide-parser.d.ts +0 -34
- package/dist/core/src/guide-parser.d.ts.map +0 -1
- package/dist/core/src/guide-parser.js +0 -136
- package/dist/core/src/guide-parser.js.map +0 -1
- package/dist/core/src/guide-schema.d.ts +0 -2
- package/dist/core/src/guide-schema.d.ts.map +0 -1
- package/dist/core/src/guide-schema.js +0 -202
- package/dist/core/src/guide-schema.js.map +0 -1
- package/dist/core/src/ignore-filter.d.ts +0 -8
- package/dist/core/src/ignore-filter.d.ts.map +0 -1
- package/dist/core/src/ignore-filter.js +0 -16
- package/dist/core/src/ignore-filter.js.map +0 -1
- package/dist/core/src/index.d.ts +0 -38
- package/dist/core/src/index.d.ts.map +0 -1
- package/dist/core/src/index.js +0 -54
- package/dist/core/src/index.js.map +0 -1
- package/dist/core/src/materializer.d.ts +0 -60
- package/dist/core/src/materializer.d.ts.map +0 -1
- package/dist/core/src/materializer.js +0 -255
- package/dist/core/src/materializer.js.map +0 -1
- package/dist/core/src/payload-sizing.d.ts +0 -20
- package/dist/core/src/payload-sizing.d.ts.map +0 -1
- package/dist/core/src/payload-sizing.js +0 -74
- package/dist/core/src/payload-sizing.js.map +0 -1
- package/dist/core/src/remote-mode.d.ts +0 -89
- package/dist/core/src/remote-mode.d.ts.map +0 -1
- package/dist/core/src/remote-mode.js +0 -193
- package/dist/core/src/remote-mode.js.map +0 -1
- package/dist/core/src/review-handlers.d.ts +0 -160
- package/dist/core/src/review-handlers.d.ts.map +0 -1
- package/dist/core/src/review-handlers.js +0 -463
- package/dist/core/src/review-handlers.js.map +0 -1
- package/dist/core/src/staged-untracked.d.ts +0 -12
- package/dist/core/src/staged-untracked.d.ts.map +0 -1
- package/dist/core/src/staged-untracked.js +0 -21
- package/dist/core/src/staged-untracked.js.map +0 -1
- package/dist/core/src/startup-mode.d.ts +0 -6
- package/dist/core/src/startup-mode.d.ts.map +0 -1
- package/dist/core/src/startup-mode.js +0 -73
- package/dist/core/src/startup-mode.js.map +0 -1
- package/dist/core/src/synthetic-diff.d.ts +0 -21
- package/dist/core/src/synthetic-diff.d.ts.map +0 -1
- package/dist/core/src/synthetic-diff.js +0 -104
- package/dist/core/src/synthetic-diff.js.map +0 -1
- package/dist/core/src/thread-mapper.d.ts +0 -39
- package/dist/core/src/thread-mapper.d.ts.map +0 -1
- package/dist/core/src/thread-mapper.js +0 -217
- package/dist/core/src/thread-mapper.js.map +0 -1
- package/dist/core/src/types.d.ts +0 -2
- package/dist/core/src/types.d.ts.map +0 -1
- package/dist/core/src/types.js +0 -2
- package/dist/core/src/types.js.map +0 -1
- package/dist/core/src/xml-parser.d.ts +0 -15
- package/dist/core/src/xml-parser.d.ts.map +0 -1
- package/dist/core/src/xml-parser.js +0 -237
- package/dist/core/src/xml-parser.js.map +0 -1
- package/dist/core/src/xml-serializer.d.ts +0 -4
- package/dist/core/src/xml-serializer.d.ts.map +0 -1
- package/dist/core/src/xml-serializer.js +0 -923
- package/dist/core/src/xml-serializer.js.map +0 -1
- package/dist/react/src/ReviewPanel.d.ts +0 -72
- package/dist/react/src/ReviewPanel.d.ts.map +0 -1
- package/dist/react/src/ReviewPanel.js +0 -51
- package/dist/react/src/ReviewPanel.js.map +0 -1
- package/dist/react/src/SingleFileReview.d.ts +0 -49
- package/dist/react/src/SingleFileReview.d.ts.map +0 -1
- package/dist/react/src/SingleFileReview.js +0 -41
- package/dist/react/src/SingleFileReview.js.map +0 -1
- package/dist/react/src/adapter.d.ts +0 -72
- package/dist/react/src/adapter.d.ts.map +0 -1
- package/dist/react/src/adapter.js +0 -2
- package/dist/react/src/adapter.js.map +0 -1
- package/dist/react/src/components/Comments/AttachmentDropZone.d.ts +0 -10
- package/dist/react/src/components/Comments/AttachmentDropZone.d.ts.map +0 -1
- package/dist/react/src/components/Comments/AttachmentDropZone.js +0 -52
- package/dist/react/src/components/Comments/AttachmentDropZone.js.map +0 -1
- package/dist/react/src/components/Comments/AttachmentImage.d.ts +0 -6
- package/dist/react/src/components/Comments/AttachmentImage.d.ts.map +0 -1
- package/dist/react/src/components/Comments/AttachmentImage.js +0 -50
- package/dist/react/src/components/Comments/AttachmentImage.js.map +0 -1
- package/dist/react/src/components/Comments/AttachmentThumbnail.d.ts +0 -6
- package/dist/react/src/components/Comments/AttachmentThumbnail.d.ts.map +0 -1
- package/dist/react/src/components/Comments/AttachmentThumbnail.js +0 -16
- package/dist/react/src/components/Comments/AttachmentThumbnail.js.map +0 -1
- package/dist/react/src/components/Comments/CategorySelector.d.ts +0 -6
- package/dist/react/src/components/Comments/CategorySelector.d.ts.map +0 -1
- package/dist/react/src/components/Comments/CategorySelector.js +0 -27
- package/dist/react/src/components/Comments/CategorySelector.js.map +0 -1
- package/dist/react/src/components/Comments/CommentDisplay.d.ts +0 -7
- package/dist/react/src/components/Comments/CommentDisplay.d.ts.map +0 -1
- package/dist/react/src/components/Comments/CommentDisplay.js +0 -103
- package/dist/react/src/components/Comments/CommentDisplay.js.map +0 -1
- package/dist/react/src/components/Comments/CommentInput.d.ts +0 -11
- package/dist/react/src/components/Comments/CommentInput.d.ts.map +0 -1
- package/dist/react/src/components/Comments/CommentInput.js +0 -81
- package/dist/react/src/components/Comments/CommentInput.js.map +0 -1
- package/dist/react/src/components/Comments/ComposerCore.d.ts +0 -49
- package/dist/react/src/components/Comments/ComposerCore.d.ts.map +0 -1
- package/dist/react/src/components/Comments/ComposerCore.js +0 -91
- package/dist/react/src/components/Comments/ComposerCore.js.map +0 -1
- package/dist/react/src/components/Comments/EmojiAutocomplete.d.ts +0 -14
- package/dist/react/src/components/Comments/EmojiAutocomplete.d.ts.map +0 -1
- package/dist/react/src/components/Comments/EmojiAutocomplete.js +0 -19
- package/dist/react/src/components/Comments/EmojiAutocomplete.js.map +0 -1
- package/dist/react/src/components/Comments/ReplyDisplay.d.ts +0 -22
- package/dist/react/src/components/Comments/ReplyDisplay.d.ts.map +0 -1
- package/dist/react/src/components/Comments/ReplyDisplay.js +0 -38
- package/dist/react/src/components/Comments/ReplyDisplay.js.map +0 -1
- package/dist/react/src/components/Comments/ReplyInput.d.ts +0 -9
- package/dist/react/src/components/Comments/ReplyInput.d.ts.map +0 -1
- package/dist/react/src/components/Comments/ReplyInput.js +0 -47
- package/dist/react/src/components/Comments/ReplyInput.js.map +0 -1
- package/dist/react/src/components/Comments/SuggestionApplyControl.d.ts +0 -27
- package/dist/react/src/components/Comments/SuggestionApplyControl.d.ts.map +0 -1
- package/dist/react/src/components/Comments/SuggestionApplyControl.js +0 -103
- package/dist/react/src/components/Comments/SuggestionApplyControl.js.map +0 -1
- package/dist/react/src/components/Comments/SuggestionBlock.d.ts +0 -26
- package/dist/react/src/components/Comments/SuggestionBlock.d.ts.map +0 -1
- package/dist/react/src/components/Comments/SuggestionBlock.js +0 -33
- package/dist/react/src/components/Comments/SuggestionBlock.js.map +0 -1
- package/dist/react/src/components/Comments/SuggestionPanel.d.ts +0 -8
- package/dist/react/src/components/Comments/SuggestionPanel.d.ts.map +0 -1
- package/dist/react/src/components/Comments/SuggestionPanel.js +0 -12
- package/dist/react/src/components/Comments/SuggestionPanel.js.map +0 -1
- package/dist/react/src/components/DiffViewer/DiffContentArea.d.ts +0 -35
- package/dist/react/src/components/DiffViewer/DiffContentArea.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/DiffContentArea.js +0 -40
- package/dist/react/src/components/DiffViewer/DiffContentArea.js.map +0 -1
- package/dist/react/src/components/DiffViewer/DiffViewer.d.ts +0 -4
- package/dist/react/src/components/DiffViewer/DiffViewer.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/DiffViewer.js +0 -110
- package/dist/react/src/components/DiffViewer/DiffViewer.js.map +0 -1
- package/dist/react/src/components/DiffViewer/EmptyDiffMessage.d.ts +0 -6
- package/dist/react/src/components/DiffViewer/EmptyDiffMessage.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/EmptyDiffMessage.js +0 -18
- package/dist/react/src/components/DiffViewer/EmptyDiffMessage.js.map +0 -1
- package/dist/react/src/components/DiffViewer/EmptyLinePane.d.ts +0 -2
- package/dist/react/src/components/DiffViewer/EmptyLinePane.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/EmptyLinePane.js +0 -5
- package/dist/react/src/components/DiffViewer/EmptyLinePane.js.map +0 -1
- package/dist/react/src/components/DiffViewer/ExpandContextBar.d.ts +0 -10
- package/dist/react/src/components/DiffViewer/ExpandContextBar.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/ExpandContextBar.js +0 -16
- package/dist/react/src/components/DiffViewer/ExpandContextBar.js.map +0 -1
- package/dist/react/src/components/DiffViewer/FileSection.d.ts +0 -9
- package/dist/react/src/components/DiffViewer/FileSection.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/FileSection.js +0 -137
- package/dist/react/src/components/DiffViewer/FileSection.js.map +0 -1
- package/dist/react/src/components/DiffViewer/FileSectionBody.d.ts +0 -13
- package/dist/react/src/components/DiffViewer/FileSectionBody.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/FileSectionBody.js +0 -8
- package/dist/react/src/components/DiffViewer/FileSectionBody.js.map +0 -1
- package/dist/react/src/components/DiffViewer/FileSectionHeader.d.ts +0 -16
- package/dist/react/src/components/DiffViewer/FileSectionHeader.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/FileSectionHeader.js +0 -53
- package/dist/react/src/components/DiffViewer/FileSectionHeader.js.map +0 -1
- package/dist/react/src/components/DiffViewer/FrontMatterTable.d.ts +0 -6
- package/dist/react/src/components/DiffViewer/FrontMatterTable.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/FrontMatterTable.js +0 -30
- package/dist/react/src/components/DiffViewer/FrontMatterTable.js.map +0 -1
- package/dist/react/src/components/DiffViewer/GuideChapterDivider.d.ts +0 -20
- package/dist/react/src/components/DiffViewer/GuideChapterDivider.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/GuideChapterDivider.js +0 -27
- package/dist/react/src/components/DiffViewer/GuideChapterDivider.js.map +0 -1
- package/dist/react/src/components/DiffViewer/GuideOverviewContent.d.ts +0 -16
- package/dist/react/src/components/DiffViewer/GuideOverviewContent.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/GuideOverviewContent.js +0 -56
- package/dist/react/src/components/DiffViewer/GuideOverviewContent.js.map +0 -1
- package/dist/react/src/components/DiffViewer/GuideOverviewDialog.d.ts +0 -12
- package/dist/react/src/components/DiffViewer/GuideOverviewDialog.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/GuideOverviewDialog.js +0 -13
- package/dist/react/src/components/DiffViewer/GuideOverviewDialog.js.map +0 -1
- package/dist/react/src/components/DiffViewer/GuideOverviewPanel.d.ts +0 -8
- package/dist/react/src/components/DiffViewer/GuideOverviewPanel.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/GuideOverviewPanel.js +0 -16
- package/dist/react/src/components/DiffViewer/GuideOverviewPanel.js.map +0 -1
- package/dist/react/src/components/DiffViewer/HunkHeader.d.ts +0 -5
- package/dist/react/src/components/DiffViewer/HunkHeader.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/HunkHeader.js +0 -5
- package/dist/react/src/components/DiffViewer/HunkHeader.js.map +0 -1
- package/dist/react/src/components/DiffViewer/InlineCommentSlot.d.ts +0 -18
- package/dist/react/src/components/DiffViewer/InlineCommentSlot.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/InlineCommentSlot.js +0 -13
- package/dist/react/src/components/DiffViewer/InlineCommentSlot.js.map +0 -1
- package/dist/react/src/components/DiffViewer/MarkdownCode.d.ts +0 -9
- package/dist/react/src/components/DiffViewer/MarkdownCode.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/MarkdownCode.js +0 -24
- package/dist/react/src/components/DiffViewer/MarkdownCode.js.map +0 -1
- package/dist/react/src/components/DiffViewer/MermaidBlock.d.ts +0 -4
- package/dist/react/src/components/DiffViewer/MermaidBlock.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/MermaidBlock.js +0 -51
- package/dist/react/src/components/DiffViewer/MermaidBlock.js.map +0 -1
- package/dist/react/src/components/DiffViewer/RenderedImageView.d.ts +0 -8
- package/dist/react/src/components/DiffViewer/RenderedImageView.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/RenderedImageView.js +0 -46
- package/dist/react/src/components/DiffViewer/RenderedImageView.js.map +0 -1
- package/dist/react/src/components/DiffViewer/RenderedMarkdownView.d.ts +0 -16
- package/dist/react/src/components/DiffViewer/RenderedMarkdownView.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/RenderedMarkdownView.js +0 -324
- package/dist/react/src/components/DiffViewer/RenderedMarkdownView.js.map +0 -1
- package/dist/react/src/components/DiffViewer/RenderedSvgView.d.ts +0 -7
- package/dist/react/src/components/DiffViewer/RenderedSvgView.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/RenderedSvgView.js +0 -21
- package/dist/react/src/components/DiffViewer/RenderedSvgView.js.map +0 -1
- package/dist/react/src/components/DiffViewer/SplitView.d.ts +0 -23
- package/dist/react/src/components/DiffViewer/SplitView.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/SplitView.js +0 -137
- package/dist/react/src/components/DiffViewer/SplitView.js.map +0 -1
- package/dist/react/src/components/DiffViewer/SyntaxLine.d.ts +0 -49
- package/dist/react/src/components/DiffViewer/SyntaxLine.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/SyntaxLine.js +0 -73
- package/dist/react/src/components/DiffViewer/SyntaxLine.js.map +0 -1
- package/dist/react/src/components/DiffViewer/UnifiedView.d.ts +0 -23
- package/dist/react/src/components/DiffViewer/UnifiedView.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/UnifiedView.js +0 -96
- package/dist/react/src/components/DiffViewer/UnifiedView.js.map +0 -1
- package/dist/react/src/components/DiffViewer/diff-utils.d.ts +0 -31
- package/dist/react/src/components/DiffViewer/diff-utils.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/diff-utils.js +0 -134
- package/dist/react/src/components/DiffViewer/diff-utils.js.map +0 -1
- package/dist/react/src/components/DiffViewer/useDragSelection.d.ts +0 -25
- package/dist/react/src/components/DiffViewer/useDragSelection.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/useDragSelection.js +0 -210
- package/dist/react/src/components/DiffViewer/useDragSelection.js.map +0 -1
- package/dist/react/src/components/DiffViewer/useExpandContext.d.ts +0 -15
- package/dist/react/src/components/DiffViewer/useExpandContext.d.ts.map +0 -1
- package/dist/react/src/components/DiffViewer/useExpandContext.js +0 -209
- package/dist/react/src/components/DiffViewer/useExpandContext.js.map +0 -1
- package/dist/react/src/components/FileTree.d.ts +0 -2
- package/dist/react/src/components/FileTree.d.ts.map +0 -1
- package/dist/react/src/components/FileTree.js +0 -93
- package/dist/react/src/components/FileTree.js.map +0 -1
- package/dist/react/src/components/FileTreeEntry.d.ts +0 -13
- package/dist/react/src/components/FileTreeEntry.d.ts.map +0 -1
- package/dist/react/src/components/FileTreeEntry.js +0 -21
- package/dist/react/src/components/FileTreeEntry.js.map +0 -1
- package/dist/react/src/components/FileTreeToggle.d.ts +0 -15
- package/dist/react/src/components/FileTreeToggle.d.ts.map +0 -1
- package/dist/react/src/components/FileTreeToggle.js +0 -16
- package/dist/react/src/components/FileTreeToggle.js.map +0 -1
- package/dist/react/src/components/GuideRouteHud.d.ts +0 -10
- package/dist/react/src/components/GuideRouteHud.d.ts.map +0 -1
- package/dist/react/src/components/GuideRouteHud.js +0 -43
- package/dist/react/src/components/GuideRouteHud.js.map +0 -1
- package/dist/react/src/components/GuideRouteMap.d.ts +0 -20
- package/dist/react/src/components/GuideRouteMap.d.ts.map +0 -1
- package/dist/react/src/components/GuideRouteMap.js +0 -58
- package/dist/react/src/components/GuideRouteMap.js.map +0 -1
- package/dist/react/src/components/GuideStation.d.ts +0 -28
- package/dist/react/src/components/GuideStation.d.ts.map +0 -1
- package/dist/react/src/components/GuideStation.js +0 -24
- package/dist/react/src/components/GuideStation.js.map +0 -1
- package/dist/react/src/components/HintOverlay.d.ts +0 -13
- package/dist/react/src/components/HintOverlay.d.ts.map +0 -1
- package/dist/react/src/components/HintOverlay.js +0 -27
- package/dist/react/src/components/HintOverlay.js.map +0 -1
- package/dist/react/src/components/KeyboardNavigationManager.d.ts +0 -2
- package/dist/react/src/components/KeyboardNavigationManager.d.ts.map +0 -1
- package/dist/react/src/components/KeyboardNavigationManager.js +0 -8
- package/dist/react/src/components/KeyboardNavigationManager.js.map +0 -1
- package/dist/react/src/components/Layout.d.ts +0 -2
- package/dist/react/src/components/Layout.d.ts.map +0 -1
- package/dist/react/src/components/Layout.js +0 -63
- package/dist/react/src/components/Layout.js.map +0 -1
- package/dist/react/src/components/ReviewProgress.d.ts +0 -2
- package/dist/react/src/components/ReviewProgress.d.ts.map +0 -1
- package/dist/react/src/components/ReviewProgress.js +0 -25
- package/dist/react/src/components/ReviewProgress.js.map +0 -1
- package/dist/react/src/components/Toolbar.d.ts +0 -6
- package/dist/react/src/components/Toolbar.d.ts.map +0 -1
- package/dist/react/src/components/Toolbar.js +0 -61
- package/dist/react/src/components/Toolbar.js.map +0 -1
- package/dist/react/src/components/TruncatedPath.d.ts +0 -7
- package/dist/react/src/components/TruncatedPath.d.ts.map +0 -1
- package/dist/react/src/components/TruncatedPath.js +0 -15
- package/dist/react/src/components/TruncatedPath.js.map +0 -1
- package/dist/react/src/components/ui/badge.d.ts +0 -10
- package/dist/react/src/components/ui/badge.d.ts.map +0 -1
- package/dist/react/src/components/ui/badge.js +0 -21
- package/dist/react/src/components/ui/badge.js.map +0 -1
- package/dist/react/src/components/ui/button.d.ts +0 -11
- package/dist/react/src/components/ui/button.d.ts.map +0 -1
- package/dist/react/src/components/ui/button.js +0 -32
- package/dist/react/src/components/ui/button.js.map +0 -1
- package/dist/react/src/components/ui/dialog.d.ts +0 -12
- package/dist/react/src/components/ui/dialog.d.ts.map +0 -1
- package/dist/react/src/components/ui/dialog.js +0 -23
- package/dist/react/src/components/ui/dialog.js.map +0 -1
- package/dist/react/src/components/ui/input.d.ts +0 -4
- package/dist/react/src/components/ui/input.d.ts.map +0 -1
- package/dist/react/src/components/ui/input.js +0 -9
- package/dist/react/src/components/ui/input.js.map +0 -1
- package/dist/react/src/components/ui/separator.d.ts +0 -6
- package/dist/react/src/components/ui/separator.d.ts.map +0 -1
- package/dist/react/src/components/ui/separator.js +0 -8
- package/dist/react/src/components/ui/separator.js.map +0 -1
- package/dist/react/src/components/ui/table.d.ts +0 -11
- package/dist/react/src/components/ui/table.d.ts.map +0 -1
- package/dist/react/src/components/ui/table.js +0 -21
- package/dist/react/src/components/ui/table.js.map +0 -1
- package/dist/react/src/components/ui/textarea.d.ts +0 -4
- package/dist/react/src/components/ui/textarea.d.ts.map +0 -1
- package/dist/react/src/components/ui/textarea.js +0 -9
- package/dist/react/src/components/ui/textarea.js.map +0 -1
- package/dist/react/src/components/ui/toggle-group.d.ts +0 -22
- package/dist/react/src/components/ui/toggle-group.d.ts.map +0 -1
- package/dist/react/src/components/ui/toggle-group.js +0 -48
- package/dist/react/src/components/ui/toggle-group.js.map +0 -1
- package/dist/react/src/components/ui/tooltip.d.ts +0 -16
- package/dist/react/src/components/ui/tooltip.d.ts.map +0 -1
- package/dist/react/src/components/ui/tooltip.js +0 -21
- package/dist/react/src/components/ui/tooltip.js.map +0 -1
- package/dist/react/src/context/ConfigContext.d.ts +0 -26
- package/dist/react/src/context/ConfigContext.d.ts.map +0 -1
- package/dist/react/src/context/ConfigContext.js +0 -150
- package/dist/react/src/context/ConfigContext.js.map +0 -1
- package/dist/react/src/context/DiffNavigationContext.d.ts +0 -16
- package/dist/react/src/context/DiffNavigationContext.d.ts.map +0 -1
- package/dist/react/src/context/DiffNavigationContext.js +0 -79
- package/dist/react/src/context/DiffNavigationContext.js.map +0 -1
- package/dist/react/src/context/GuideContext.d.ts +0 -28
- package/dist/react/src/context/GuideContext.d.ts.map +0 -1
- package/dist/react/src/context/GuideContext.js +0 -64
- package/dist/react/src/context/GuideContext.js.map +0 -1
- package/dist/react/src/context/ReviewAdapterContext.d.ts +0 -9
- package/dist/react/src/context/ReviewAdapterContext.d.ts.map +0 -1
- package/dist/react/src/context/ReviewAdapterContext.js +0 -10
- package/dist/react/src/context/ReviewAdapterContext.js.map +0 -1
- package/dist/react/src/context/ReviewContext.d.ts +0 -60
- package/dist/react/src/context/ReviewContext.d.ts.map +0 -1
- package/dist/react/src/context/ReviewContext.js +0 -233
- package/dist/react/src/context/ReviewContext.js.map +0 -1
- package/dist/react/src/hooks/useDiffNavigation.d.ts +0 -4
- package/dist/react/src/hooks/useDiffNavigation.d.ts.map +0 -1
- package/dist/react/src/hooks/useDiffNavigation.js +0 -5
- package/dist/react/src/hooks/useDiffNavigation.js.map +0 -1
- package/dist/react/src/hooks/useEmojiAutocomplete.d.ts +0 -24
- package/dist/react/src/hooks/useEmojiAutocomplete.d.ts.map +0 -1
- package/dist/react/src/hooks/useEmojiAutocomplete.js +0 -175
- package/dist/react/src/hooks/useEmojiAutocomplete.js.map +0 -1
- package/dist/react/src/hooks/useKeyboardNavigation.d.ts +0 -15
- package/dist/react/src/hooks/useKeyboardNavigation.d.ts.map +0 -1
- package/dist/react/src/hooks/useKeyboardNavigation.js +0 -227
- package/dist/react/src/hooks/useKeyboardNavigation.js.map +0 -1
- package/dist/react/src/hooks/useReviewBridge.d.ts +0 -15
- package/dist/react/src/hooks/useReviewBridge.d.ts.map +0 -1
- package/dist/react/src/hooks/useReviewBridge.js +0 -43
- package/dist/react/src/hooks/useReviewBridge.js.map +0 -1
- package/dist/react/src/hooks/useReviewState.d.ts +0 -16
- package/dist/react/src/hooks/useReviewState.d.ts.map +0 -1
- package/dist/react/src/hooks/useReviewState.js +0 -101
- package/dist/react/src/hooks/useReviewState.js.map +0 -1
- package/dist/react/src/index.d.ts +0 -25
- package/dist/react/src/index.d.ts.map +0 -1
- package/dist/react/src/index.js +0 -22
- package/dist/react/src/index.js.map +0 -1
- package/dist/react/src/lib/utils.d.ts +0 -3
- package/dist/react/src/lib/utils.d.ts.map +0 -1
- package/dist/react/src/lib/utils.js +0 -6
- package/dist/react/src/lib/utils.js.map +0 -1
- package/dist/react/src/utils/category-utils.d.ts +0 -17
- package/dist/react/src/utils/category-utils.d.ts.map +0 -1
- package/dist/react/src/utils/category-utils.js +0 -23
- package/dist/react/src/utils/category-utils.js.map +0 -1
- package/dist/react/src/utils/comment-anchors.d.ts +0 -4
- package/dist/react/src/utils/comment-anchors.d.ts.map +0 -1
- package/dist/react/src/utils/comment-anchors.js +0 -17
- package/dist/react/src/utils/comment-anchors.js.map +0 -1
- package/dist/react/src/utils/diff-styles.d.ts +0 -12
- package/dist/react/src/utils/diff-styles.d.ts.map +0 -1
- package/dist/react/src/utils/diff-styles.js +0 -46
- package/dist/react/src/utils/diff-styles.js.map +0 -1
- package/dist/react/src/utils/emoji-data.d.ts +0 -8
- package/dist/react/src/utils/emoji-data.d.ts.map +0 -1
- package/dist/react/src/utils/emoji-data.js +0 -43
- package/dist/react/src/utils/emoji-data.js.map +0 -1
- package/dist/react/src/utils/file-type-utils.d.ts +0 -20
- package/dist/react/src/utils/file-type-utils.d.ts.map +0 -1
- package/dist/react/src/utils/file-type-utils.js +0 -110
- package/dist/react/src/utils/file-type-utils.js.map +0 -1
- package/dist/react/src/utils/front-matter.d.ts +0 -14
- package/dist/react/src/utils/front-matter.d.ts.map +0 -1
- package/dist/react/src/utils/front-matter.js +0 -40
- package/dist/react/src/utils/front-matter.js.map +0 -1
- package/dist/react/src/utils/guide-accents.d.ts +0 -46
- package/dist/react/src/utils/guide-accents.d.ts.map +0 -1
- package/dist/react/src/utils/guide-accents.js +0 -100
- package/dist/react/src/utils/guide-accents.js.map +0 -1
- package/dist/react/src/utils/guide-display.d.ts +0 -48
- package/dist/react/src/utils/guide-display.d.ts.map +0 -1
- package/dist/react/src/utils/guide-display.js +0 -75
- package/dist/react/src/utils/guide-display.js.map +0 -1
- package/dist/react/src/utils/image-utils.d.ts +0 -3
- package/dist/react/src/utils/image-utils.d.ts.map +0 -1
- package/dist/react/src/utils/image-utils.js +0 -33
- package/dist/react/src/utils/image-utils.js.map +0 -1
- package/dist/react/src/utils/passive-content.d.ts +0 -9
- package/dist/react/src/utils/passive-content.d.ts.map +0 -1
- package/dist/react/src/utils/passive-content.js +0 -135
- package/dist/react/src/utils/passive-content.js.map +0 -1
- package/dist/react/src/utils/remark-emoji.d.ts +0 -3
- package/dist/react/src/utils/remark-emoji.d.ts.map +0 -1
- package/dist/react/src/utils/remark-emoji.js +0 -38
- package/dist/react/src/utils/remark-emoji.js.map +0 -1
- package/dist/serve/src/args.d.ts +0 -15
- package/dist/serve/src/args.d.ts.map +0 -1
- package/dist/serve/src/args.js +0 -65
- package/dist/serve/src/args.js.map +0 -1
- package/dist/serve/src/cli.d.ts +0 -3
- package/dist/serve/src/cli.d.ts.map +0 -1
- package/dist/serve/src/cli.js +0 -81
- package/dist/serve/src/cli.js.map +0 -1
- package/dist/serve/src/client/adapter.d.ts +0 -25
- package/dist/serve/src/client/adapter.d.ts.map +0 -1
- package/dist/serve/src/client/adapter.js +0 -190
- package/dist/serve/src/client/adapter.js.map +0 -1
- package/dist/serve/src/client/index.d.ts +0 -2
- package/dist/serve/src/client/index.d.ts.map +0 -1
- package/dist/serve/src/client/index.js +0 -135
- package/dist/serve/src/client/index.js.map +0 -1
- package/dist/serve/src/lifecycle.d.ts +0 -27
- package/dist/serve/src/lifecycle.d.ts.map +0 -1
- package/dist/serve/src/lifecycle.js +0 -73
- package/dist/serve/src/lifecycle.js.map +0 -1
- package/dist/serve/src/server.d.ts +0 -34
- package/dist/serve/src/server.d.ts.map +0 -1
- package/dist/serve/src/server.js +0 -430
- package/dist/serve/src/server.js.map +0 -1
- package/dist/serve/src/startup.d.ts +0 -19
- package/dist/serve/src/startup.d.ts.map +0 -1
- package/dist/serve/src/startup.js +0 -117
- package/dist/serve/src/startup.js.map +0 -1
- package/dist/serve/src/validate.d.ts +0 -44
- package/dist/serve/src/validate.d.ts.map +0 -1
- package/dist/serve/src/validate.js +0 -295
- package/dist/serve/src/validate.js.map +0 -1
- package/dist/types/src/index.d.ts +0 -417
- package/dist/types/src/index.d.ts.map +0 -1
- package/dist/types/src/index.js +0 -5
- package/dist/types/src/index.js.map +0 -1
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/args.ts","../src/startup.ts","../src/lifecycle.ts","../src/server.ts","../src/validate.ts"],"sourcesContent":["#!/usr/bin/env node\n\n// The serve-mode entry point: resolve one review session, serve it on a\n// port, and stop when the review is complete.\n//\n// Composition only — argument parsing is ./args, session resolution is\n// ./startup, the routes are ./server and the completion is ./lifecycle. The\n// order below is the load-bearing part: the session is fully resolved, and\n// the completion hook attached, before the listener opens, so no request can\n// reach a half-built session and no submission can arrive unobserved.\n\nimport { createRequire } from 'node:module';\nimport { parseServeArgs } from './args';\nimport { resolveSession } from './startup';\nimport { completeReviewOnSubmit } from './lifecycle';\nimport { createReviewServer, listenLoopback } from './server';\n\nconst HELP = `\nself-review-serve - Serve the self-review interface over HTTP\n\nUsage: self-review-serve [options] [<git-diff-args>...]\n\nOptions:\n -o, --output <file> Write the review to <file> (default: ./review.xml, or\n output-file from .self-review.yaml)\n --resume-from <file> Load a previous review XML file\n -h, --help Show this help message\n -v, --version Show version number\n\nAll other arguments are passed to git diff. With none, the unstaged working\ntree changes are reviewed. Outside a git repository, pass a directory or file.\n\nExamples:\n self-review-serve # unstaged changes\n self-review-serve --staged\n self-review-serve main..feature-branch\n self-review-serve --resume-from review.xml # resume a previous review\n\nThe URL is printed to stderr on start. The output path is fixed by the\narguments above and cannot be changed from the browser. Completing the review\nwrites that file and stops this process. Nothing is saved before then, and\nclosing the tab once you have written a comment warns you first.\n\nThe listener binds to 127.0.0.1 and refuses any request that names another\nhost or origin, so a web page cannot reach it. There is no authentication:\nanything that can reach the port can read the diff and complete the review,\nwhich on a shared host means every local user. An ssh -L forward works.\n`.trim();\n\nfunction printVersion(): void {\n try {\n // Read at runtime rather than imported, so the version is the installed\n // package's own. dist/cli.js sits one directory below package.json in\n // both the workspace and an installed tarball.\n const requireFromHere = createRequire(import.meta.url);\n const pkg = requireFromHere('../package.json') as { version: string };\n console.error(`self-review-serve v${pkg.version}`);\n } catch {\n console.error('self-review-serve (version unknown)');\n }\n}\n\nasync function main(): Promise<void> {\n const args = parseServeArgs(process.argv.slice(2));\n if (args.help) {\n console.error(HELP);\n return;\n }\n if (args.version) {\n printVersion();\n return;\n }\n\n const { session, repositoryRoot, outputPath } = await resolveSession(args);\n\n const server = createReviewServer({ session, repositoryRoot });\n completeReviewOnSubmit({ server, session, outputPath });\n\n const { url } = await listenLoopback(server);\n console.error(`[serve] Review ready at ${url}`);\n console.error(`[serve] Completing the review writes ${outputPath} and stops this process.`);\n console.error('[serve] The listener is loopback-only and unauthenticated.');\n}\n\nmain().catch(error => {\n console.error(`[serve] ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n});\n","// Mirrors the desktop's parser (src/main/cli.ts): anything the program does not\n// claim is passed to `git diff` verbatim. The output path is fixed for the life\n// of the process — a browser has no equivalent of the native save dialog.\n\nexport interface ServeArgs {\n /** Arguments passed through to `git diff`, in the order given. */\n gitDiffArgs: string[];\n /**\n * Output path exactly as typed, unresolved. `null` means the caller said\n * nothing and the configured `output-file` decides.\n */\n outputPath: string | null;\n /** Path of a prior review XML to resume from, as typed. `null` when unset. */\n resumeFrom: string | null;\n help: boolean;\n version: boolean;\n}\n\nconst VALUE_FLAGS: Record<string, 'outputPath' | 'resumeFrom'> = {\n '--output': 'outputPath',\n '-o': 'outputPath',\n '--resume-from': 'resumeFrom',\n};\n\n/**\n * Parse serve-mode arguments. Throws on a value-taking flag with no value:\n * silently passing `--output` to `git diff` would fail much further away\n * from the mistake, with a message about a revision.\n */\n/**\n * An empty value is a mistake, not a request for the default: `--output=`\n * resolves to the working directory, which passes the writability check and\n * then fails with EISDIR at submit, once the review has left the session.\n */\nfunction requireValue(flag: string, value: string): string {\n if (value === '') {\n throw new Error(`${flag} requires a file path argument`);\n }\n return value;\n}\n\nexport function parseServeArgs(argv: string[]): ServeArgs {\n const args: ServeArgs = {\n gitDiffArgs: [],\n outputPath: null,\n resumeFrom: null,\n help: false,\n version: false,\n };\n\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n\n if (arg === '--help' || arg === '-h') {\n args.help = true;\n continue;\n }\n if (arg === '--version' || arg === '-v') {\n args.version = true;\n continue;\n }\n\n // Accepted alongside the separated form, so `=` is never a git revision.\n const equals = arg.indexOf('=');\n if (equals > 0) {\n const field = VALUE_FLAGS[arg.slice(0, equals)];\n if (field) {\n args[field] = requireValue(arg.slice(0, equals), arg.slice(equals + 1));\n continue;\n }\n }\n\n const field = VALUE_FLAGS[arg];\n if (field) {\n if (i + 1 >= argv.length) {\n throw new Error(`${arg} requires a file path argument`);\n }\n args[field] = requireValue(arg, argv[i + 1]);\n i++;\n continue;\n }\n\n args.gitDiffArgs.push(arg);\n }\n\n return args;\n}\n","// Resolve one review session the way the desktop does. Each phase below cites\n// the phase of `initializeApp` (src/main/main.ts) it mirrors.\n//\n// Two orderings are load-bearing: everything resolves before the caller opens\n// the listener, so no request races a half-built session; and the guide lands\n// on the session during startup, since `GET /api/diff` answers from there.\n//\n// The desktop's large-payload prompt and directory picker are native dialogs\n// with no browser equivalent, so the first becomes automatic and the second\n// becomes a startup error.\n\nimport { resolve } from 'node:path';\nimport {\n applyStagedUntrackedDefault,\n checkWritability,\n computePayloadStats,\n countTotalLines,\n createIgnoreFilter,\n createReviewSession,\n determineMode,\n loadConfig,\n loadGitDiffWithUntracked,\n loadGuide,\n normalizeGitDiffArgs,\n parseReviewXml,\n scanDirectory,\n scanFile,\n} from '@self-review/core';\nimport type { AppConfig, DiffLoadPayload, ReviewSession } from '@self-review/core';\nimport type { ServeArgs } from './args';\n\nexport interface ServeStartup {\n /** The resolved session, complete: diff, guide, config and resume state. */\n session: ReviewSession;\n /**\n * Root every request-supplied path is contained under: the same value core\n * resolves against, since containment guarantees nothing unless they agree.\n */\n repositoryRoot: string;\n /** Absolute output path, fixed for the lifetime of the process. */\n outputPath: string;\n}\n\n/**\n * Mirrors main.ts phase 4. Welcome mode diverges: there is no directory picker\n * in a browser, so refusing beats serving an interface whose controls are dead.\n */\nasync function loadDiffForMode(gitDiffArgs: string[], config: AppConfig): Promise<DiffLoadPayload> {\n const mode = determineMode(gitDiffArgs);\n console.error(`[serve] Startup mode: ${mode}`);\n\n if (mode === 'git') {\n const { files, repository } = await loadGitDiffWithUntracked(gitDiffArgs);\n const shouldKeep = createIgnoreFilter(config.ignore);\n return {\n files: files.filter(f => shouldKeep(f.newPath || f.oldPath)),\n source: { type: 'git', gitDiffArgs: gitDiffArgs.join(' '), repository },\n };\n }\n\n if (mode === 'file') {\n const fileArg = gitDiffArgs.find(a => a !== '--' && !a.startsWith('-'))!;\n const sourcePath = resolve(process.cwd(), fileArg);\n return { files: await scanFile(sourcePath), source: { type: 'file', sourcePath } };\n }\n\n if (mode === 'directory') {\n const dirArg = gitDiffArgs.find(a => a !== '--' && !a.startsWith('-'))!;\n const sourcePath = resolve(process.cwd(), dirArg);\n return {\n files: await scanDirectory(sourcePath, config.ignore),\n source: { type: 'directory', sourcePath },\n };\n }\n\n throw new Error(\n 'Nothing to review: this is not a git repository and no path was given. ' +\n 'Run self-review-serve inside a git repository, or pass a directory or file to review.'\n );\n}\n\n/** The root core resolves a diff path against — see `ServeStartup.repositoryRoot`. */\nfunction containmentRoot(payload: DiffLoadPayload): string {\n return payload.source.type === 'git' ? payload.source.repository : process.cwd();\n}\n\n/**\n * Resolve the session to serve. Throws when there is nothing to review or the\n * resume file cannot be read; the caller reports and exits.\n */\nexport async function resolveSession(args: ServeArgs): Promise<ServeStartup> {\n // Phase 2 (main.ts:163) — configuration and the output path. Fixed here\n // and never again: no route changes it.\n let config = loadConfig();\n const outputPath = resolve(process.cwd(), args.outputPath ?? config.outputFile);\n // The desktop offers a save dialog out of this; the browser has no such\n // control, so a reviewer would have no exit. Fail before the work, not after.\n if (!checkWritability(outputPath)) {\n throw new Error(\n `Output path is not writable: ${outputPath}. ` +\n 'Pass a writable path with --output, or set output-file in .self-review.yaml.'\n );\n }\n console.error(`[serve] Output path: ${outputPath}`);\n\n // Phase 3 (main.ts:169) — git diff arguments, normalized so a path can\n // never be read as a revision, then the staged/untracked default.\n let gitDiffArgs = args.gitDiffArgs;\n if (gitDiffArgs.length === 0 && config.defaultDiffArgs) {\n gitDiffArgs = config.defaultDiffArgs.split(' ').filter(a => a.length > 0);\n }\n gitDiffArgs = normalizeGitDiffArgs(gitDiffArgs);\n config = applyStagedUntrackedDefault(config, gitDiffArgs);\n\n // Phase 4 (main.ts:189) — what to review.\n const diffData = await loadDiffForMode(gitDiffArgs, config);\n console.error(`[serve] Loaded ${diffData.files.length} files`);\n\n // Phase 4b (main.ts:264) — large payload. The desktop asks; there is\n // nobody to ask before the browser connects, so the threshold simply\n // turns on lazy per-file loading (GET /api/file) and says so.\n const stats = computePayloadStats(diffData.files.length, countTotalLines(diffData.files), config);\n if (stats.exceedsAny) {\n console.error(\n `[serve] Large payload: ${stats.fileCount} files, ${stats.totalLines} lines ` +\n `(thresholds ${config.maxFiles} files, ${config.maxTotalLines} lines) — ` +\n 'serving file contents on demand'\n );\n diffData.isLargePayload = true;\n }\n\n // Phase 5 (main.ts:295) — resume a prior review.\n const session = createReviewSession();\n if (args.resumeFrom) {\n const resumePath = resolve(process.cwd(), args.resumeFrom);\n let parsed: ReturnType<typeof parseReviewXml>;\n try {\n parsed = parseReviewXml(resumePath);\n } catch (error) {\n throw new Error(\n `Could not read the resume file ${resumePath}: ` +\n (error instanceof Error ? error.message : String(error))\n );\n }\n session.resumeComments = parsed.comments;\n session.resumeViewedFiles = parsed.viewedFiles;\n console.error(\n `[serve] Resumed ${parsed.comments.length} comments and ` +\n `${parsed.viewedFiles.length} viewed files from ${resumePath}`\n );\n }\n\n // Phase 5b (main.ts:337) — the walkthrough guide sidecar, discovered next\n // to the output path. Tolerant by contract: loadGuide never throws.\n const guideData = await loadGuide(\n outputPath,\n config,\n diffData.files.map(f => f.newPath || f.oldPath)\n );\n if (guideData) {\n console.error(`[serve] Walkthrough guide loaded: ${guideData.groups.length} groups`);\n }\n\n // Phase 6 (main.ts:350) — assemble. Everything the routes read is on the\n // session before the caller opens the listener.\n session.diffData = diffData;\n session.guideData = guideData;\n session.config = config;\n // Always writable: startup refused above if it was not.\n session.outputPathInfo = { resolvedOutputPath: outputPath, outputPathWritable: true };\n\n return { session, repositoryRoot: containmentRoot(diffData), outputPath };\n}\n","// Process lifetime is review lifetime. Completing writes the file and stops the\n// process; nothing else does. A closed tab is not an event this program sees.\n\nimport * as fs from 'node:fs';\nimport type * as http from 'node:http';\nimport { serializeReview, takeReviewState } from '@self-review/core';\nimport type { ReviewSession, ReviewState } from '@self-review/core';\n\nexport interface CompletionOptions {\n /** The listener to stop once the review is written. */\n server: http.Server;\n /** The session `POST /api/review` submits into. */\n session: ReviewSession;\n /** Absolute output path, fixed at startup. */\n outputPath: string;\n /** Injected so a test can observe the exit code. Defaults to `process.exit`. */\n exit?: (code: number) => void;\n}\n\n/**\n * The same two steps the desktop takes on Finish Review. A document that fails\n * XSD validation throws, and nothing is written.\n */\nexport async function writeReviewOutput(state: ReviewState, outputPath: string): Promise<void> {\n const xml = await serializeReview(state, outputPath);\n fs.writeFileSync(outputPath, xml + '\\n', 'utf-8');\n}\n\n/**\n * Closes open connections too, or a browser's idle keep-alive socket holds the\n * port after the process is done with it.\n */\nfunction shutdown(server: http.Server, exit: (code: number) => void, code: number): void {\n server.closeAllConnections();\n server.close();\n exit(code);\n}\n\n/**\n * The hook is the response, not the route: `finish` fires once the response is\n * flushed, so the browser has its answer before the socket goes away. A 4xx is\n * not a completion and is ignored.\n *\n * Because the write follows the response, a 200 means accepted, not written —\n * so an end-to-end test must assert the file, never the status code.\n */\nexport function completeReviewOnSubmit(options: CompletionOptions): void {\n const { server, session, outputPath, exit = process.exit } = options;\n let completing = false;\n\n server.on('request', (req, res) => {\n if (req.method !== 'POST' || pathnameOf(req.url) !== '/api/review') {\n return;\n }\n res.on('finish', () => {\n if (res.statusCode !== 200 || completing) {\n return;\n }\n completing = true;\n void complete(server, session, outputPath, exit);\n });\n });\n}\n\nfunction pathnameOf(url: string | undefined): string | null {\n try {\n return new URL(url ?? '/', 'http://localhost').pathname;\n } catch {\n return null;\n }\n}\n\nasync function complete(\n server: http.Server,\n session: ReviewSession,\n outputPath: string,\n exit: (code: number) => void\n): Promise<void> {\n // Taken, not read: consumed exactly once, and this is the only consumer.\n const state = takeReviewState(session);\n if (!state) {\n console.error('[serve] Review submission accepted but no state was recorded');\n shutdown(server, exit, 1);\n return;\n }\n\n try {\n await writeReviewOutput(state, outputPath);\n } catch (error) {\n console.error(\n `[serve] Error saving review: ${error instanceof Error ? error.message : String(error)}`\n );\n shutdown(server, exit, 1);\n return;\n }\n\n console.error(`[serve] Review written to ${outputPath}`);\n shutdown(server, exit, 0);\n}\n","// Eight JSON routes over one ReviewSession, each a thin wrapper over a function\n// core already exports, plus static serving for the client bundle. node:http,\n// no framework.\n//\n// Two properties are load-bearing: every route validates before core runs, and\n// the listener both binds to loopback and refuses requests that name anything\n// else. Binding alone is not enough — a web page can reach a loopback port, and\n// DNS rebinding would make it same-origin. There is no authentication.\n\nimport * as fs from 'node:fs';\nimport * as http from 'node:http';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { AddressInfo } from 'node:net';\nimport {\n getDiffLoad,\n getConfigLoad,\n getResumeLoad,\n getFileHunks,\n loadImage,\n readAttachment,\n expandContext,\n submitReviewState,\n applySuggestionForSession,\n} from '@self-review/core';\nimport type { ReviewSession } from '@self-review/core';\nimport {\n containPath,\n parseExpandContextBody,\n parseReviewStateBody,\n parseSuggestionApplyBody,\n} from './validate';\n\n/** `client/` next to this module, which is `dist/client/` once built. */\nexport const CLIENT_DIR = fileURLToPath(new URL('./client/', import.meta.url));\n\n/** Upper bound on a `POST /api/expand-context` body: a path and an integer. */\nexport const MAX_EXPAND_CONTEXT_BODY_BYTES = 64 * 1024;\n\n/** Generous but finite: an unbounded read is a trivial denial of service. */\nexport const MAX_REVIEW_BODY_BYTES = 32 * 1024 * 1024;\n\nexport interface ReviewServerOptions {\n /** The session every route acts on; held for the process lifetime. */\n session: ReviewSession;\n /**\n * Root every request-supplied path is contained under. Must match what core\n * resolves against, or containment guarantees nothing.\n */\n repositoryRoot: string;\n /** Directory of the client bundle. Defaults to `CLIENT_DIR`; tests inject a fixture. */\n clientDir?: string;\n}\n\ninterface RouteContext {\n req: http.IncomingMessage;\n res: http.ServerResponse;\n url: URL;\n session: ReviewSession;\n repositoryRoot: string;\n}\n\ntype RouteHandler = (ctx: RouteContext) => Promise<void>;\n\nconst CONTENT_TYPES: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'text/javascript; charset=utf-8',\n '.mjs': 'text/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.map': 'application/json; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.ico': 'image/x-icon',\n '.woff': 'font/woff',\n '.woff2': 'font/woff2',\n '.txt': 'text/plain; charset=utf-8',\n};\n\n/**\n * The page renders the diff under review, which is the least trusted input the\n * program handles. Rendered content is sanitized before it becomes elements;\n * this is the second line, for whatever gets past that.\n *\n * Inline styles are allowed because index.html carries a <style> block and\n * bundled libraries inject at runtime; blob: because attachments display\n * through createObjectURL.\n */\nconst CSP = [\n \"default-src 'self'\",\n \"script-src 'self'\",\n \"style-src 'self' 'unsafe-inline'\",\n \"img-src 'self' data: blob:\",\n \"font-src 'self' data:\",\n \"connect-src 'self'\",\n \"frame-src 'none'\",\n \"child-src 'none'\",\n \"object-src 'none'\",\n \"base-uri 'none'\",\n \"form-action 'none'\",\n \"frame-ancestors 'none'\",\n].join('; ');\n\nconst SECURITY_HEADERS: http.OutgoingHttpHeaders = {\n 'content-security-policy': CSP,\n 'x-content-type-options': 'nosniff',\n 'x-frame-options': 'DENY',\n 'referrer-policy': 'no-referrer',\n};\n\n/** A browser may resolve the printed URL either way, or prefer IPv6. */\nconst LOOPBACK_HOSTNAMES: ReadonlySet<string> = new Set(['127.0.0.1', 'localhost', '[::1]']);\n\n/** Lowercased, with an explicit `:80` dropped so it matches the bare host. */\nfunction normalizeHost(value: string): string {\n const lowered = value.toLowerCase();\n return lowered.endsWith(':80') ? lowered.slice(0, -3) : lowered;\n}\n\n/**\n * A rebound request — an attacker's name re-resolved to 127.0.0.1 after the\n * page loads — still carries that name in `Host`, which is what distinguishes\n * it from a real one.\n *\n * The port is deliberately not compared against the bound port: an `ssh -L`\n * forward arrives carrying the forward's port, and refusing that would break\n * the use case this package exists for. It would buy nothing either, since a\n * rebound request fails on the hostname first.\n *\n * A duplicate `Host` is refused, not resolved: Node reads the first, and an\n * intermediary forwarding the last would be reading a different request.\n */\nfunction hostIsLoopback(req: http.IncomingMessage): boolean {\n const host = req.headers.host;\n if (host === undefined) return false;\n\n let seen = 0;\n for (let i = 0; i < req.rawHeaders.length; i += 2) {\n if (req.rawHeaders[i].toLowerCase() === 'host') seen++;\n }\n if (seen !== 1) return false;\n\n // Split the optional port off, keeping an IPv6 literal's brackets.\n const match = /^(\\[[^\\]]*\\]|[^:]*)(?::(\\d+))?$/.exec(host);\n if (match === null) return false;\n return LOOPBACK_HOSTNAMES.has(match[1].toLowerCase());\n}\n\n/**\n * A missing `Origin` is allowed — navigations and curl send none. Rejected is\n * an `Origin` naming a different authority than `Host`, including the `null` a\n * sandboxed frame sends.\n *\n * Comparing against `Host` rather than a loopback allowlist is what survives a\n * port forward while still refusing another local page: a dev server on :3000\n * sends its own origin and this listener's host, and those differ.\n */\nfunction originMatchesHost(req: http.IncomingMessage): boolean {\n const origin = req.headers.origin;\n if (origin === undefined) return true;\n const host = req.headers.host;\n if (host === undefined) return false;\n let parsed: URL;\n try {\n parsed = new URL(origin);\n } catch {\n return false;\n }\n if (parsed.protocol !== 'http:') return false;\n // `new URL` parses away userinfo, paths and leading-zero ports, any of which\n // would compare equal to this authority. A browser sends none of them.\n if (origin !== `${parsed.protocol}//${parsed.host}`) return false;\n return normalizeHost(parsed.host) === normalizeHost(host);\n}\n\n/**\n * Set by the browser, unforgeable by page script. A cross-site *GET* — an <img>\n * aimed at this port — carries no `Origin`, so without this it would be served\n * and only the absence of CORS headers would stop the page reading it.\n *\n * Non-browser clients send no such header and are unaffected.\n */\nfunction fetchSiteIsSelf(req: http.IncomingMessage): boolean {\n const site = req.headers['sec-fetch-site'];\n if (site === undefined) return true;\n return site === 'same-origin' || site === 'none';\n}\n\nfunction sendJson(\n res: http.ServerResponse,\n status: number,\n value: unknown,\n headers: http.OutgoingHttpHeaders = {}\n): void {\n res.writeHead(status, {\n 'content-type': 'application/json; charset=utf-8',\n 'cache-control': 'no-store',\n ...SECURITY_HEADERS,\n ...headers,\n });\n // `JSON.stringify(undefined)` is undefined; a void core result becomes `null`.\n res.end(JSON.stringify(value ?? null));\n}\n\nfunction sendError(res: http.ServerResponse, status: number, error: string): void {\n // A body that blew the cap is not read further; close the connection rather\n // than let the rest of it be reinterpreted as a next request.\n sendJson(res, status, { error }, status === 413 ? { connection: 'close' } : {});\n}\n\n/**\n * Contain the `path` parameter under the repository root. Returns it both as\n * sent (core interprets it relative to the repository) and resolved (for a\n * handler reading disk directly), or answers 400 and returns null.\n */\nfunction requireContainedPath(ctx: RouteContext): { raw: string; resolved: string } | null {\n const raw = ctx.url.searchParams.get('path');\n const resolved = raw ? containPath(ctx.repositoryRoot, raw) : null;\n if (raw === null || resolved === null) {\n sendError(ctx.res, 400, 'path must be a file under the repository root');\n return null;\n }\n return { raw, resolved };\n}\n\ntype BodyResult = { ok: true; value: unknown } | { ok: false; status: number; error: string };\n\n/**\n * The declared length is checked before a byte is read and the running total\n * during it, so a chunked body without a length is capped too.\n */\nfunction readJsonBody(req: http.IncomingMessage, maxBytes: number): Promise<BodyResult> {\n const contentType = req.headers['content-type'] ?? '';\n if (!contentType.toLowerCase().startsWith('application/json')) {\n return Promise.resolve({\n ok: false,\n status: 415,\n error: 'content-type must be application/json',\n });\n }\n const declared = Number(req.headers['content-length']);\n if (Number.isFinite(declared) && declared > maxBytes) {\n return Promise.resolve({ ok: false, status: 413, error: 'request body too large' });\n }\n\n return new Promise(resolve => {\n const chunks: Buffer[] = [];\n let received = 0;\n req.on('data', (chunk: Buffer) => {\n received += chunk.length;\n if (received > maxBytes) {\n chunks.length = 0;\n req.removeAllListeners('data');\n req.removeAllListeners('end');\n resolve({ ok: false, status: 413, error: 'request body too large' });\n return;\n }\n chunks.push(chunk);\n });\n req.on('end', () => {\n try {\n resolve({ ok: true, value: JSON.parse(Buffer.concat(chunks).toString('utf-8')) });\n } catch {\n resolve({ ok: false, status: 400, error: 'body must be valid JSON' });\n }\n });\n req.on('error', () => {\n resolve({ ok: false, status: 400, error: 'request body could not be read' });\n });\n });\n}\n\n// Each route validates, calls exactly one core function, and sends its result.\n\nconst routes: Record<string, RouteHandler> = {\n 'GET /api/diff': async ({ res, session }) => {\n // The guide rides with the diff, so the client needs no push channel.\n sendJson(res, 200, getDiffLoad(session));\n },\n\n 'GET /api/config': async ({ res, session }) => {\n sendJson(res, 200, getConfigLoad(session));\n },\n\n 'GET /api/resume': async ({ res, session }) => {\n sendJson(res, 200, getResumeLoad(session));\n },\n\n 'GET /api/file': async ctx => {\n const contained = requireContainedPath(ctx);\n if (contained === null) return;\n // Diff paths are repository-relative strings; core matches on them as sent.\n sendJson(ctx.res, 200, getFileHunks(ctx.session, contained.raw));\n },\n\n 'GET /api/image': async ctx => {\n const contained = requireContainedPath(ctx);\n if (contained === null) return;\n // Core resolves against the repository itself, so it gets the raw value.\n sendJson(ctx.res, 200, await loadImage(ctx.session, contained.raw));\n },\n\n 'GET /api/attachment': async ctx => {\n // A different namespace from diff paths, and a different root: review.xml\n // records these relative to the output file's directory. Rooting them at\n // the repository 404s every resumed image when -o points elsewhere.\n const assetRoot = ctx.session.outputPathInfo\n ? path.dirname(ctx.session.outputPathInfo.resolvedOutputPath)\n : ctx.repositoryRoot;\n const raw = ctx.url.searchParams.get('path');\n const resolved = raw ? containPath(assetRoot, raw) : null;\n if (resolved === null) {\n sendError(ctx.res, 400, 'path must be a file under the output directory');\n return;\n }\n // Core reads this path from disk directly, so it gets the contained real path.\n const data = await readAttachment(resolved);\n if (data === null) {\n sendError(ctx.res, 404, 'attachment not found');\n return;\n }\n const { res } = ctx;\n res.writeHead(200, {\n 'content-type': 'application/octet-stream',\n 'cache-control': 'no-store',\n ...SECURITY_HEADERS,\n });\n res.end(Buffer.from(data));\n },\n\n 'POST /api/expand-context': async ({ req, res, session, repositoryRoot }) => {\n const body = await readJsonBody(req, MAX_EXPAND_CONTEXT_BODY_BYTES);\n if (!body.ok) {\n sendError(res, body.status, body.error);\n return;\n }\n const parsed = parseExpandContextBody(body.value);\n if (!parsed.ok) {\n sendError(res, 400, parsed.error);\n return;\n }\n // Becomes a git pathspec; contain it, then pass it through as sent.\n if (containPath(repositoryRoot, parsed.value.filePath) === null) {\n sendError(res, 400, 'filePath must be a file under the repository root');\n return;\n }\n sendJson(res, 200, await expandContext(session, parsed.value));\n },\n\n // The one route that rewrites a file in the reviewed tree. Core refuses\n // unless the anchored lines still match the suggestion's recorded original\n // byte for byte, and resolves the destination itself; the path is contained\n // here so a request cannot even name a file outside the repository.\n 'POST /api/apply-suggestion': async ({ req, res, session, repositoryRoot }) => {\n const body = await readJsonBody(req, MAX_EXPAND_CONTEXT_BODY_BYTES);\n if (!body.ok) {\n sendError(res, body.status, body.error);\n return;\n }\n const parsed = parseSuggestionApplyBody(body.value);\n if (!parsed.ok) {\n sendError(res, 400, parsed.error);\n return;\n }\n if (containPath(repositoryRoot, parsed.value.filePath) === null) {\n sendError(res, 400, 'filePath must be a file under the repository root');\n return;\n }\n sendJson(res, 200, applySuggestionForSession(session, parsed.value));\n },\n\n 'POST /api/review': async ({ req, res, session }) => {\n const body = await readJsonBody(req, MAX_REVIEW_BODY_BYTES);\n if (!body.ok) {\n sendError(res, body.status, body.error);\n return;\n }\n const parsed = parseReviewStateBody(body.value);\n if (!parsed.ok) {\n sendError(res, 400, parsed.error);\n return;\n }\n submitReviewState(session, parsed.value);\n sendJson(res, 200, null);\n },\n};\n\nconst ROUTE_PATHS = new Set(Object.keys(routes).map(key => key.split(' ')[1]));\n\n/**\n * `/` is index.html; everything else is contained under the client directory.\n * Anything that is not a regular file under it is a 404.\n */\nasync function serveStatic(\n res: http.ServerResponse,\n clientDir: string,\n pathname: string\n): Promise<void> {\n let decoded: string;\n try {\n decoded = decodeURIComponent(pathname);\n } catch {\n sendError(res, 404, 'not found');\n return;\n }\n const relative = decoded === '/' ? 'index.html' : decoded.replace(/^\\/+/, '');\n const resolved = containPath(clientDir, relative);\n if (resolved === null) {\n sendError(res, 404, 'not found');\n return;\n }\n\n let data: Buffer;\n try {\n const stat = await fs.promises.stat(resolved);\n if (!stat.isFile()) {\n sendError(res, 404, 'not found');\n return;\n }\n data = await fs.promises.readFile(resolved);\n } catch {\n sendError(res, 404, 'not found');\n return;\n }\n res.writeHead(200, {\n 'content-type':\n CONTENT_TYPES[path.extname(resolved).toLowerCase()] ?? 'application/octet-stream',\n 'content-length': data.length,\n ...SECURITY_HEADERS,\n });\n res.end(data);\n}\n\n/**\n * Taking the session explicitly rather than reading module state mirrors the\n * core handlers and lets a test drive this without a repository. Not yet\n * listening: bind it with `listenLoopback`.\n */\nexport function createReviewServer(options: ReviewServerOptions): http.Server {\n const { session, repositoryRoot, clientDir = CLIENT_DIR } = options;\n\n return http.createServer(async (req, res) => {\n const method = req.method ?? 'GET';\n let url: URL;\n try {\n url = new URL(req.url ?? '/', 'http://localhost');\n } catch {\n sendError(res, 400, 'malformed request URL');\n return;\n }\n\n // Before anything is routed: this listener answers only to itself.\n if (!hostIsLoopback(req) || !originMatchesHost(req) || !fetchSiteIsSelf(req)) {\n sendError(res, 403, 'forbidden');\n return;\n }\n\n try {\n const handler = routes[`${method} ${url.pathname}`];\n if (handler) {\n await handler({ req, res, url, session, repositoryRoot });\n } else if (ROUTE_PATHS.has(url.pathname)) {\n sendError(res, 405, 'method not allowed');\n } else if (url.pathname.startsWith('/api/')) {\n sendError(res, 404, 'not found');\n } else if (method === 'GET') {\n await serveStatic(res, clientDir, url.pathname);\n } else {\n sendError(res, 404, 'not found');\n }\n } catch (error) {\n console.error(`[serve] ${method} ${url.pathname} failed:`, error);\n if (!res.headersSent) {\n sendError(res, 500, 'internal error');\n } else {\n res.end();\n }\n }\n });\n}\n\n/**\n * The address is fixed here, not left to the caller: never `0.0.0.0`, never the\n * default. Port 0 asks the OS for an ephemeral one.\n */\nexport function listenLoopback(\n server: http.Server,\n port = 0\n): Promise<{ port: number; url: string }> {\n return new Promise((resolve, reject) => {\n server.once('error', reject);\n server.listen(port, '127.0.0.1', () => {\n server.off('error', reject);\n const address = server.address() as AddressInfo;\n resolve({ port: address.port, url: `http://127.0.0.1:${address.port}/` });\n });\n });\n}\n","// Request validation for the serve package. Core's handlers assume a caller the\n// compiler checked; over HTTP the body is whatever the socket delivered.\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type { ExpandContextRequest, ReviewState, SuggestionApplyRequest } from '@self-review/core';\n\n/** Realpath the deepest existing ancestor, so a deleted file still resolves. */\nfunction realpathDeepestExisting(absolute: string): string | null {\n const missing: string[] = [];\n let current = absolute;\n for (;;) {\n try {\n const real = fs.realpathSync(current);\n return missing.length === 0 ? real : path.join(real, ...missing);\n } catch {\n const parent = path.dirname(current);\n if (parent === current) {\n return null;\n }\n missing.unshift(path.basename(current));\n current = parent;\n }\n }\n}\n\n/**\n * Resolve `candidate` under `root`, or null if it escapes.\n *\n * Never decode here: callers pass a value `searchParams` already decoded once,\n * and decoding again turns `%2E%2E%2F` inside a filename into a real traversal.\n */\nexport function containPath(root: string, candidate: string): string | null {\n let resolvedRoot: string;\n try {\n resolvedRoot = fs.realpathSync(root);\n } catch {\n return null;\n }\n\n // Realpath both sides so a symlink inside the repository cannot escape it.\n const resolved = realpathDeepestExisting(path.resolve(resolvedRoot, candidate));\n if (resolved === null) {\n return null;\n }\n\n if (resolved === resolvedRoot) {\n return resolved;\n }\n // Root plus separator, not a bare prefix: `/repo-evil` is not under `/repo`.\n const rootWithSep = resolvedRoot.endsWith(path.sep) ? resolvedRoot : resolvedRoot + path.sep;\n return resolved.startsWith(rootWithSep) ? resolved : null;\n}\n\n/**\n * Reaches git as `-U${contextLines}`, so it must be bounded. Matches\n * `MAX_CONTEXT` in useExpandContext.ts; keep the two in step.\n */\nexport const MAX_CONTEXT_LINES = 99_999;\n\nexport type ParseResult<T> = { ok: true; value: T } | { ok: false; error: string };\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nconst EXPAND_CONTEXT_KEYS: ReadonlySet<string> = new Set(['filePath', 'contextLines']);\n\n/**\n * Accepts exactly `{ filePath, contextLines }`. Unknown keys are rejected, not\n * ignored. The route contains `filePath` with `containPath` before git sees it.\n */\nexport function parseExpandContextBody(body: unknown): ParseResult<ExpandContextRequest> {\n if (typeof body !== 'object' || body === null || Array.isArray(body)) {\n return { ok: false, error: 'body must be a JSON object' };\n }\n const record = body as Record<string, unknown>;\n\n for (const key of Object.keys(record)) {\n if (!EXPAND_CONTEXT_KEYS.has(key)) {\n return { ok: false, error: `unknown field: ${key}` };\n }\n }\n\n const { filePath, contextLines } = record;\n if (typeof filePath !== 'string') {\n return { ok: false, error: 'filePath must be a string' };\n }\n if (\n typeof contextLines !== 'number' ||\n !Number.isInteger(contextLines) ||\n contextLines < 0 ||\n contextLines > MAX_CONTEXT_LINES\n ) {\n return {\n ok: false,\n error: `contextLines must be an integer between 0 and ${MAX_CONTEXT_LINES}`,\n };\n }\n\n return { ok: true, value: { filePath, contextLines } };\n}\n\nconst APPLY_KEYS: ReadonlySet<string> = new Set(['filePath', 'lineRange', 'suggestion']);\nconst LINE_RANGE_KEYS: ReadonlySet<string> = new Set(['side', 'start', 'end']);\nconst SUGGESTION_KEYS: ReadonlySet<string> = new Set(['originalCode', 'proposedCode']);\n\n/**\n * Validate the body of `POST /api/apply-suggestion`.\n *\n * This is the one route that rewrites a file in the reviewed tree, so the shape\n * is checked exactly rather than deferred. Core refuses anything whose anchored\n * lines do not still match `originalCode` byte for byte, but it should never be\n * asked a question this malformed in the first place.\n */\nexport function parseSuggestionApplyBody(body: unknown): ParseResult<SuggestionApplyRequest> {\n if (!isRecord(body)) {\n return { ok: false, error: 'body must be a JSON object' };\n }\n for (const key of Object.keys(body)) {\n if (!APPLY_KEYS.has(key)) return { ok: false, error: `unknown field: ${key}` };\n }\n\n const { filePath, lineRange, suggestion } = body;\n if (typeof filePath !== 'string' || filePath === '') {\n return { ok: false, error: 'filePath must be a non-empty string' };\n }\n\n // A file-level comment has no anchor, and core refuses it. Accept the null so\n // the refusal comes back in core's vocabulary rather than as a 400.\n if (lineRange !== null) {\n if (!isRecord(lineRange)) {\n return { ok: false, error: 'lineRange must be an object or null' };\n }\n for (const key of Object.keys(lineRange)) {\n if (!LINE_RANGE_KEYS.has(key)) {\n return { ok: false, error: `unknown lineRange field: ${key}` };\n }\n }\n if (lineRange.side !== 'old' && lineRange.side !== 'new') {\n return { ok: false, error: \"lineRange.side must be 'old' or 'new'\" };\n }\n for (const key of ['start', 'end'] as const) {\n const value = lineRange[key];\n if (typeof value !== 'number' || !Number.isInteger(value) || value < 1) {\n return { ok: false, error: `lineRange.${key} must be a positive integer` };\n }\n }\n if ((lineRange.end as number) < (lineRange.start as number)) {\n return { ok: false, error: 'lineRange.end must not precede lineRange.start' };\n }\n }\n\n if (!isRecord(suggestion)) {\n return { ok: false, error: 'suggestion must be an object' };\n }\n for (const key of Object.keys(suggestion)) {\n if (!SUGGESTION_KEYS.has(key)) {\n return { ok: false, error: `unknown suggestion field: ${key}` };\n }\n }\n for (const key of ['originalCode', 'proposedCode'] as const) {\n if (typeof suggestion[key] !== 'string') {\n return { ok: false, error: `suggestion.${key} must be a string` };\n }\n }\n\n return { ok: true, value: body as unknown as SuggestionApplyRequest };\n}\n\nconst REVIEW_STATE_KEYS: ReadonlySet<string> = new Set(['timestamp', 'source', 'files']);\n\n/**\n * Accepts exactly `{ timestamp, source, files }`. Remote provenance is never\n * taken from the client; the process injects it after submission.\n *\n * Structural only — the XSD checks nested fields at serialization time. The\n * exception is `id`, checked below, because the serializer turns an id into a\n * file name *before* it validates anything.\n */\nexport function parseReviewStateBody(body: unknown): ParseResult<ReviewState> {\n if (typeof body !== 'object' || body === null || Array.isArray(body)) {\n return { ok: false, error: 'body must be a JSON object' };\n }\n const record = body as Record<string, unknown>;\n\n for (const key of Object.keys(record)) {\n if (!REVIEW_STATE_KEYS.has(key)) {\n return { ok: false, error: `unknown field: ${key}` };\n }\n }\n\n const { timestamp, source, files } = record;\n if (typeof timestamp !== 'string') {\n return { ok: false, error: 'timestamp must be a string' };\n }\n if (typeof source !== 'object' || source === null || Array.isArray(source)) {\n return { ok: false, error: 'source must be an object' };\n }\n if (!Array.isArray(files)) {\n return { ok: false, error: 'files must be an array' };\n }\n\n const decoded = decodeFileAttachments(files);\n if (!decoded.ok) {\n return decoded;\n }\n\n return { ok: true, value: { timestamp, source, files: decoded.value } as ReviewState };\n}\n\n// Attachment blobs on the wire. `JSON.stringify` renders an ArrayBuffer as\n// `{}`, which would write a zero-byte image with a 200 and no error anywhere,\n// so the client sends base64 in `dataBase64` and a raw `data` field is refused.\n\n/** Canonical base64: full quartets, with at most one padded tail group. */\nconst BASE64_PATTERN =\n /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)$/;\n\nconst RAW_DATA_ERROR =\n 'attachment data must be sent base64-encoded as dataBase64, never as a serialized ArrayBuffer';\n\n/** Every id this app makes: a randomUUID, or generateId's `${ms}-${base36}`. */\nconst ID_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;\n\n/**\n * An id becomes an attachment's file name, so `../../x` was a path. Core\n * contains that write too; refusing here fails with a 400 at the door rather\n * than midway through saving, once the review has left the session.\n */\nfunction checkId(entry: Record<string, unknown>, what: string): string | null {\n if (entry.id === undefined) return null;\n if (typeof entry.id !== 'string' || !ID_PATTERN.test(entry.id)) {\n return `${what} id must match ${ID_PATTERN.source}`;\n }\n return null;\n}\n\n/**\n * The slice is load-bearing: `Buffer.from` returns a view into Node's shared\n * pool, so handing `.buffer` over whole writes unrelated memory to disk.\n */\nfunction base64ToArrayBuffer(value: string): ArrayBuffer {\n const buffer = Buffer.from(value, 'base64');\n return buffer.buffer.slice(\n buffer.byteOffset,\n buffer.byteOffset + buffer.byteLength\n ) as ArrayBuffer;\n}\n\n/** Decode each blob. A resumed attachment carries none and passes through. */\nfunction decodeAttachmentList(list: unknown[]): ParseResult<unknown[]> {\n const decoded: unknown[] = [];\n for (const entry of list) {\n if (!isRecord(entry)) {\n decoded.push(entry);\n continue;\n }\n if (entry.data !== undefined) {\n return { ok: false, error: RAW_DATA_ERROR };\n }\n if (entry.dataBase64 === undefined) {\n decoded.push(entry);\n continue;\n }\n const encoded = entry.dataBase64;\n if (typeof encoded !== 'string' || !BASE64_PATTERN.test(encoded)) {\n // The empty string fails the pattern too: an attachment with no bytes\n // is a zero-byte file on disk, which is the failure being guarded.\n return { ok: false, error: 'attachment dataBase64 must be non-empty base64' };\n }\n const { dataBase64: _encoded, ...rest } = entry;\n decoded.push({ ...rest, data: base64ToArrayBuffer(encoded) });\n }\n return { ok: true, value: decoded };\n}\n\n/**\n * Walk the files, decoding blobs and checking every id that becomes a file\n * name. Tolerant of anything it does not recognise, since the XSD checks the\n * document later; strict about the encoding, which the XSD cannot see.\n */\nfunction decodeFileAttachments(files: unknown[]): ParseResult<unknown[]> {\n const decodedFiles: unknown[] = [];\n for (const file of files) {\n if (!isRecord(file) || !Array.isArray(file.comments)) {\n decodedFiles.push(file);\n continue;\n }\n const decodedComments: unknown[] = [];\n for (const comment of file.comments) {\n if (!isRecord(comment)) {\n decodedComments.push(comment);\n continue;\n }\n const commentIdError = checkId(comment, 'comment');\n if (commentIdError) return { ok: false, error: commentIdError };\n const next: Record<string, unknown> = { ...comment };\n\n if (Array.isArray(comment.attachments)) {\n const result = decodeAttachmentList(comment.attachments);\n if (!result.ok) return result;\n next.attachments = result.value;\n }\n\n if (Array.isArray(comment.replies)) {\n const decodedReplies: unknown[] = [];\n for (const reply of comment.replies) {\n if (!isRecord(reply)) {\n decodedReplies.push(reply);\n continue;\n }\n const replyIdError = checkId(reply, 'reply');\n if (replyIdError) return { ok: false, error: replyIdError };\n if (!Array.isArray(reply.attachments)) {\n decodedReplies.push(reply);\n continue;\n }\n const result = decodeAttachmentList(reply.attachments);\n if (!result.ok) return result;\n decodedReplies.push({ ...reply, attachments: result.value });\n }\n next.replies = decodedReplies;\n }\n\n decodedComments.push(next);\n }\n decodedFiles.push({ ...file, comments: decodedComments });\n }\n return { ok: true, value: decodedFiles };\n}\n"],"mappings":";;;AAWA,SAAS,qBAAqB;;;ACO9B,IAAM,cAA2D;AAAA,EAC/D,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,iBAAiB;AACnB;AAYA,SAAS,aAAa,MAAc,OAAuB;AACzD,MAAI,UAAU,IAAI;AAChB,UAAM,IAAI,MAAM,GAAG,IAAI,gCAAgC;AAAA,EACzD;AACA,SAAO;AACT;AAEO,SAAS,eAAe,MAA2B;AACxD,QAAM,OAAkB;AAAA,IACtB,aAAa,CAAC;AAAA,IACd,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAEA,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,MAAM,KAAK,CAAC;AAElB,QAAI,QAAQ,YAAY,QAAQ,MAAM;AACpC,WAAK,OAAO;AACZ;AAAA,IACF;AACA,QAAI,QAAQ,eAAe,QAAQ,MAAM;AACvC,WAAK,UAAU;AACf;AAAA,IACF;AAGA,UAAM,SAAS,IAAI,QAAQ,GAAG;AAC9B,QAAI,SAAS,GAAG;AACd,YAAMA,SAAQ,YAAY,IAAI,MAAM,GAAG,MAAM,CAAC;AAC9C,UAAIA,QAAO;AACT,aAAKA,MAAK,IAAI,aAAa,IAAI,MAAM,GAAG,MAAM,GAAG,IAAI,MAAM,SAAS,CAAC,CAAC;AACtE;AAAA,MACF;AAAA,IACF;AAEA,UAAM,QAAQ,YAAY,GAAG;AAC7B,QAAI,OAAO;AACT,UAAI,IAAI,KAAK,KAAK,QAAQ;AACxB,cAAM,IAAI,MAAM,GAAG,GAAG,gCAAgC;AAAA,MACxD;AACA,WAAK,KAAK,IAAI,aAAa,KAAK,KAAK,IAAI,CAAC,CAAC;AAC3C;AACA;AAAA,IACF;AAEA,S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AAU,OAAO,KAAK,CAAC,EAAE;AACjF,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["field","fs","path","fs","resolve"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/args.ts","../src/startup.ts","../src/lifecycle.ts","../src/server.ts","../src/validate.ts","../src/capability.ts","../src/protocol.ts"],"sourcesContent":["#!/usr/bin/env node\n\n// The serve-mode entry point: resolve one review session, serve it on a\n// port, and stop when the review is complete.\n//\n// Composition only — argument parsing is ./args, session resolution is\n// ./startup, the routes are ./server and the completion is ./lifecycle. The\n// order below is the load-bearing part: the session is fully resolved, and\n// the completion hook attached, before the listener opens, so no request can\n// reach a half-built session and no submission can arrive unobserved.\n\nimport { createRequire } from 'node:module';\nimport { parseServeArgs } from './args';\nimport { resolveSession } from './startup';\nimport { completeReviewOnSubmit } from './lifecycle';\nimport { createReviewServer, listenLoopback } from './server';\nimport { generateCapability } from './capability';\nimport { formatLaunchUrl } from './protocol';\n\nconst HELP = `\nself-review-serve - Serve the self-review interface over HTTP\n\nUsage: self-review-serve [options] [<git-diff-args>...]\n\nOptions:\n -o, --output <file> Write the review to <file> (default: ./review.xml, or\n output-file from .self-review.yaml)\n --resume-from <file> Load a previous review XML file\n -h, --help Show this help message\n -v, --version Show version number\n\nAll other arguments are passed to git diff. With none, the unstaged working\ntree changes are reviewed. Outside a git repository, pass a directory or file.\n\nExamples:\n self-review-serve # unstaged changes\n self-review-serve --staged\n self-review-serve main..feature-branch\n self-review-serve --resume-from review.xml # resume a previous review\n\nThe URL is printed to stderr on start. Open exactly that URL: the part after\n'#' is this session's key, drawn fresh each start, and the browser keeps it\nout of the address bar once the page has loaded. A reloaded or retyped\naddress has no key and the page says so; if the URL is lost, stop this\nprocess and start it again. Over ssh, forward the port (ssh -L) and open the\nsame URL against the forwarded port, keeping the '#' part.\n\nThe output path is fixed by the arguments above and cannot be changed from\nthe browser. Completing the review writes that file and stops this process.\nNothing is saved before then, and closing the tab once you have written a\ncomment warns you first. If the file cannot be written, the browser says why\nand keeps the review; fix the problem and press Finish Review again.\n\nThe listener binds to 127.0.0.1, refuses any request that names another host\nor origin so a web page cannot reach it, and refuses any API request without\nthe key, so another account on the same host cannot either.\n`.trim();\n\nfunction printVersion(): void {\n try {\n // Read at runtime rather than imported, so the version is the installed\n // package's own. dist/cli.js sits one directory below package.json in\n // both the workspace and an installed tarball.\n const requireFromHere = createRequire(import.meta.url);\n const pkg = requireFromHere('../package.json') as { version: string };\n console.error(`self-review-serve v${pkg.version}`);\n } catch {\n console.error('self-review-serve (version unknown)');\n }\n}\n\nasync function main(): Promise<void> {\n const args = parseServeArgs(process.argv.slice(2));\n if (args.help) {\n console.error(HELP);\n return;\n }\n if (args.version) {\n printVersion();\n return;\n }\n\n const { session, output } = await resolveSession(args);\n\n // Leaves only in the printed URL's fragment; the server never sends it.\n const capability = generateCapability();\n const server = createReviewServer({ session, output, capability });\n completeReviewOnSubmit({ server });\n\n const { url } = await listenLoopback(server);\n console.error(`[serve] Review ready at ${formatLaunchUrl(url, capability)}`);\n console.error(`[serve] Completing the review writes ${output.path} and stops this process.`);\n console.error(\n '[serve] The listener is loopback-only. The part of the URL after # is this ' +\n \"session's key: open the URL exactly as printed, and do not share it.\"\n );\n}\n\nmain().catch(error => {\n console.error(`[serve] ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n});\n","// Mirrors src/main/cli.ts over core's extractor; the flag table is in packages/core/src/startup.ts.\n\nimport { extractApplicationOptions } from '@self-review/core';\n\nexport interface ServeArgs {\n /** Arguments passed through to `git diff`, in the order given. */\n gitDiffArgs: string[];\n /**\n * Output path exactly as typed, unresolved. `null` means the caller said\n * nothing and the configured `output-file` decides.\n */\n outputPath: string | null;\n /** Path of a prior review XML to resume from, as typed. `null` when unset. */\n resumeFrom: string | null;\n help: boolean;\n version: boolean;\n}\n\nconst VALUE_FLAGS = {\n '--output': 'outputPath',\n '-o': 'outputPath',\n '--resume-from': 'resumeFrom',\n} as const;\n\nconst BOOLEAN_FLAGS = {\n '--help': 'help',\n '-h': 'help',\n '--version': 'version',\n '-v': 'version',\n} as const;\n\n// Throws ApplicationOptionError on a value flag with no or an empty value: `--output=` would otherwise\n// resolve to the working directory and fail with EISDIR only at submit.\nexport function parseServeArgs(argv: string[]): ServeArgs {\n const { values, flags, rest } = extractApplicationOptions(argv, {\n valueFlags: VALUE_FLAGS,\n booleanFlags: BOOLEAN_FLAGS,\n });\n return {\n gitDiffArgs: rest,\n outputPath: values.outputPath,\n resumeFrom: values.resumeFrom,\n help: flags.help,\n version: flags.version,\n };\n}\n","// Resolve one review session the way the desktop does. Each phase below cites\n// the phase of `initializeApp` (src/main/main.ts) it mirrors; the shared decisions are core's startup module.\n//\n// Two orderings are load-bearing: everything resolves before the caller opens\n// the listener, so no request races a half-built session; and the guide lands\n// on the session during startup, since `GET /api/diff` answers from there.\n//\n// The desktop's large-payload prompt and directory picker are native dialogs\n// with no browser equivalent, so the first becomes automatic and the second\n// becomes a startup error.\n\nimport { resolve } from 'node:path';\nimport {\n commitDiffData,\n computePayloadStats,\n countTotalLines,\n createReviewSession,\n inspectOutputPath,\n loadConfigWithProvenance,\n loadGuide,\n loadLocalReview,\n loadResumeDocument,\n publishOptionsFor,\n resolveOutputTarget,\n resolveStartupDiffArgs,\n resolveStartupSource,\n} from '@self-review/core';\nimport type { ReviewOutputTarget, ReviewSession } from '@self-review/core';\nimport type { ServeArgs } from './args';\n\nexport interface ServeStartup {\n /** Carries the source identity every path-taking route authorizes against (audit A6). */\n session: ReviewSession;\n /** Fixed for the process lifetime. */\n output: ReviewOutputTarget;\n}\n\nconst log = (message: string) => console.error(`[serve] ${message}`);\n\n/** Throws when startup cannot produce a servable session; the caller reports and exits. */\nexport async function resolveSession(args: ServeArgs): Promise<ServeStartup> {\n // Phase 2 (main.ts): configuration and the output path.\n const cwd = process.cwd();\n const loadedConfig = loadConfigWithProvenance({ cwd });\n const output = resolveOutputTarget(args.outputPath, loadedConfig, cwd);\n // Advisory (the publisher re-checks at submit), but refusing an output that can never be written beats serving a review with no way out.\n const problem = inspectOutputPath(output.path, publishOptionsFor(output));\n if (problem) {\n throw new Error(\n `Output path is not writable (${problem.code}): ${problem.message} ` +\n 'Pass a writable path with --output, or set output-file in .self-review.yaml.'\n );\n }\n log(`Output path: ${output.path} (${output.origin})`);\n\n // Phase 3 (main.ts): git diff arguments.\n const { gitDiffArgs, config } = resolveStartupDiffArgs(args.gitDiffArgs, loadedConfig, cwd);\n\n // Phase 4 (main.ts): what to review. Welcome mode is refused: a browser has no directory picker.\n const source = resolveStartupSource(gitDiffArgs, cwd);\n log(`Startup mode: ${source.mode}`);\n if (source.mode === 'welcome') {\n throw new Error(\n 'Nothing to review: this is not a git repository and no path was given. ' +\n 'Run self-review-serve inside a git repository, or pass a directory or file to review.'\n );\n }\n const { payload: diffData, identity } = await loadLocalReview(\n source,\n gitDiffArgs,\n config,\n cwd,\n log\n );\n log(`Loaded ${diffData.files.length} files`);\n\n // Phase 4b (main.ts): large payload. Nobody to ask before the browser connects, so lazy loading just turns on.\n const stats = computePayloadStats(diffData.files.length, countTotalLines(diffData.files), config);\n if (stats.exceedsAny) {\n log(\n `Large payload: ${stats.fileCount} files, ${stats.totalLines} lines ` +\n `(thresholds ${config.maxFiles} files, ${config.maxTotalLines} lines) — ` +\n 'serving file contents on demand'\n );\n diffData.isLargePayload = true;\n }\n\n // Phase 5 (main.ts): resume.\n const session = createReviewSession();\n if (args.resumeFrom) {\n const resumePath = resolve(cwd, args.resumeFrom);\n try {\n loadResumeDocument(session, resumePath);\n } catch (error) {\n throw new Error(\n `Could not read the resume file ${resumePath}: ` +\n (error instanceof Error ? error.message : String(error))\n );\n }\n log(\n `Resumed ${session.resumeComments.length} comments and ` +\n `${session.resumeViewedFiles.length} viewed files from ${resumePath}`\n );\n for (const diagnostic of session.resumeImportDiagnostics) {\n log(`Resume import: ${diagnostic}`);\n }\n }\n\n // Phase 5b (main.ts): guide sidecar. It must be on the session before listening; GET /api/diff answers from there.\n const guideData = await loadGuide(\n output.path,\n config,\n diffData.files.map(f => f.newPath || f.oldPath)\n );\n if (guideData) {\n log(`Walkthrough guide loaded: ${guideData.groups.length} groups`);\n }\n\n // Phase 6 (main.ts) — assemble. Everything the routes read is on the\n // session before the caller opens the listener.\n // commitDiffData captures the reviewed paths that authorize every apply, and the source identity.\n commitDiffData(session, diffData, identity);\n session.guideData = guideData;\n session.config = config;\n session.outputPathInfo = { resolvedOutputPath: output.path, outputPathWritable: true };\n\n return { session, output };\n}\n","// A published review stops the process; nothing else does. `POST /api/review` (./server.ts) publishes before it answers, so a flushed 200 means the file is on disk.\n\nimport type * as http from 'node:http';\n\nexport interface CompletionOptions {\n server: http.Server;\n /** Injected so a test can observe the exit code. Defaults to `process.exit`. */\n exit?: (code: number) => void;\n}\n\n/**\n * Closes open connections too, or a browser's idle keep-alive socket holds the\n * port after the process is done with it.\n */\nfunction shutdown(server: http.Server, exit: (code: number) => void, code: number): void {\n server.closeAllConnections();\n server.close();\n exit(code);\n}\n\n/**\n * The hook is the response, not the route: `finish` fires once the response is\n * flushed, so the browser has its answer before the socket goes away. Only a\n * 200 is a completion.\n */\nexport function completeReviewOnSubmit(options: CompletionOptions): void {\n const { server, exit = process.exit } = options;\n let completing = false;\n\n server.on('request', (req, res) => {\n if (req.method !== 'POST' || pathnameOf(req.url) !== '/api/review') {\n return;\n }\n res.on('finish', () => {\n if (res.statusCode !== 200 || completing) {\n return;\n }\n completing = true;\n console.error('[serve] Review complete; stopping.');\n shutdown(server, exit, 0);\n });\n });\n}\n\nfunction pathnameOf(url: string | undefined): string | null {\n try {\n return new URL(url ?? '/', 'http://localhost').pathname;\n } catch {\n return null;\n }\n}\n","// Nine JSON routes over one ReviewSession, each a thin wrapper over a function\n// core already exports, plus static serving for the client bundle. node:http,\n// no framework.\n//\n// Three properties are load-bearing: every route validates before core runs; the listener both binds\n// to loopback and refuses requests that name anything else (a web page can reach loopback, and DNS\n// rebinding would make it same-origin); and every API route requires the session capability (see ./protocol.ts).\n// `POST /api/review` publishes before it answers.\n\nimport * as fs from 'node:fs';\nimport * as http from 'node:http';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { AddressInfo } from 'node:net';\nimport {\n authorizeReviewedPath,\n getDiffLoad,\n getConfigLoad,\n getResumeLoad,\n getFileHunks,\n loadImage,\n parseAttachmentReference,\n readAttachment,\n expandContext,\n submitReviewState,\n applySuggestionForSession,\n publishOptionsFor,\n publishReview,\n ReviewPublishError,\n} from '@self-review/core';\nimport type {\n ReviewOutputTarget as CoreReviewOutputTarget,\n ReviewPublishErrorCode,\n ReviewSession,\n ReviewState,\n} from '@self-review/core';\nimport {\n containPath,\n parseExpandContextBody,\n parseReviewStateBody,\n parseSuggestionApplyBody,\n} from './validate';\nimport { capabilityMatches } from './capability';\nimport { CAPABILITY_SCHEME, MAX_REVIEW_BODY_BYTES } from './protocol';\nimport type { ReviewSubmitAck, ReviewSubmitFailure } from './protocol';\n\nexport { MAX_REVIEW_BODY_BYTES } from './protocol';\n\n// Resolved on demand: `import.meta.url` is not a `file:` URL under the client suite's browser-like environment.\nexport function defaultClientDir(): string {\n return fileURLToPath(new URL('./client/', import.meta.url));\n}\n\n/** Upper bound on a `POST /api/expand-context` body: a path and an integer. */\nexport const MAX_EXPAND_CONTEXT_BODY_BYTES = 64 * 1024;\n\nexport type ReviewOutputTarget = CoreReviewOutputTarget;\n\nexport interface ReviewServerOptions {\n /** Every request-supplied diff path is authorized against this session's source identity by core (audit A6). */\n session: ReviewSession;\n output: ReviewOutputTarget;\n /** Bearer token every `/api/` request must present; the server never sends it. */\n capability: string;\n /** Directory of the client bundle. Defaults to `defaultClientDir()`; tests inject a fixture. */\n clientDir?: string;\n}\n\ninterface RouteContext {\n req: http.IncomingMessage;\n res: http.ServerResponse;\n url: URL;\n session: ReviewSession;\n output: ReviewOutputTarget;\n}\n\ntype RouteHandler = (ctx: RouteContext) => Promise<void>;\n\nconst CONTENT_TYPES: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'text/javascript; charset=utf-8',\n '.mjs': 'text/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.map': 'application/json; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.ico': 'image/x-icon',\n '.woff': 'font/woff',\n '.woff2': 'font/woff2',\n '.txt': 'text/plain; charset=utf-8',\n};\n\n/**\n * The page renders the diff under review, which is the least trusted input the\n * program handles. Rendered content is sanitized before it becomes elements;\n * this is the second line, for whatever gets past that.\n *\n * Inline styles are allowed because index.html carries a <style> block and\n * bundled libraries inject at runtime; blob: because attachments display\n * through createObjectURL.\n */\nconst CSP = [\n \"default-src 'self'\",\n \"script-src 'self'\",\n \"style-src 'self' 'unsafe-inline'\",\n \"img-src 'self' data: blob:\",\n \"font-src 'self' data:\",\n \"connect-src 'self'\",\n \"frame-src 'none'\",\n \"child-src 'none'\",\n \"object-src 'none'\",\n \"base-uri 'none'\",\n \"form-action 'none'\",\n \"frame-ancestors 'none'\",\n].join('; ');\n\nconst SECURITY_HEADERS: http.OutgoingHttpHeaders = {\n 'content-security-policy': CSP,\n 'x-content-type-options': 'nosniff',\n 'x-frame-options': 'DENY',\n 'referrer-policy': 'no-referrer',\n};\n\n/** A browser may resolve the printed URL either way, or prefer IPv6. */\nconst LOOPBACK_HOSTNAMES: ReadonlySet<string> = new Set(['127.0.0.1', 'localhost', '[::1]']);\n\n/** Lowercased, with an explicit `:80` dropped so it matches the bare host. */\nfunction normalizeHost(value: string): string {\n const lowered = value.toLowerCase();\n return lowered.endsWith(':80') ? lowered.slice(0, -3) : lowered;\n}\n\n/**\n * A rebound request — an attacker's name re-resolved to 127.0.0.1 after the\n * page loads — still carries that name in `Host`, which is what distinguishes\n * it from a real one.\n *\n * The port is deliberately not compared against the bound port: an `ssh -L`\n * forward arrives carrying the forward's port, and refusing that would break\n * the use case this package exists for. It would buy nothing either, since a\n * rebound request fails on the hostname first.\n *\n * A duplicate `Host` is refused, not resolved: Node reads the first, and an\n * intermediary forwarding the last would be reading a different request.\n */\nfunction hostIsLoopback(req: http.IncomingMessage): boolean {\n const host = req.headers.host;\n if (host === undefined) return false;\n\n let seen = 0;\n for (let i = 0; i < req.rawHeaders.length; i += 2) {\n if (req.rawHeaders[i].toLowerCase() === 'host') seen++;\n }\n if (seen !== 1) return false;\n\n // Split the optional port off, keeping an IPv6 literal's brackets.\n const match = /^(\\[[^\\]]*\\]|[^:]*)(?::(\\d+))?$/.exec(host);\n if (match === null) return false;\n return LOOPBACK_HOSTNAMES.has(match[1].toLowerCase());\n}\n\n/**\n * A missing `Origin` is allowed — navigations and curl send none. Rejected is\n * an `Origin` naming a different authority than `Host`, including the `null` a\n * sandboxed frame sends.\n *\n * Comparing against `Host` rather than a loopback allowlist is what survives a\n * port forward while still refusing another local page: a dev server on :3000\n * sends its own origin and this listener's host, and those differ.\n */\nfunction originMatchesHost(req: http.IncomingMessage): boolean {\n const origin = req.headers.origin;\n if (origin === undefined) return true;\n const host = req.headers.host;\n if (host === undefined) return false;\n let parsed: URL;\n try {\n parsed = new URL(origin);\n } catch {\n return false;\n }\n if (parsed.protocol !== 'http:') return false;\n // `new URL` parses away userinfo, paths and leading-zero ports, any of which\n // would compare equal to this authority. A browser sends none of them.\n if (origin !== `${parsed.protocol}//${parsed.host}`) return false;\n return normalizeHost(parsed.host) === normalizeHost(host);\n}\n\n/**\n * Set by the browser, unforgeable by page script. A cross-site *GET* — an <img>\n * aimed at this port — carries no `Origin`, so without this it would be served\n * and only the absence of CORS headers would stop the page reading it.\n *\n * Non-browser clients send no such header and are unaffected.\n */\nfunction fetchSiteIsSelf(req: http.IncomingMessage): boolean {\n const site = req.headers['sec-fetch-site'];\n if (site === undefined) return true;\n return site === 'same-origin' || site === 'none';\n}\n\nfunction sendJson(\n res: http.ServerResponse,\n status: number,\n value: unknown,\n headers: http.OutgoingHttpHeaders = {}\n): void {\n res.writeHead(status, {\n 'content-type': 'application/json; charset=utf-8',\n 'cache-control': 'no-store',\n ...SECURITY_HEADERS,\n ...headers,\n });\n // `JSON.stringify(undefined)` is undefined; a void core result becomes `null`.\n res.end(JSON.stringify(value ?? null));\n}\n\nfunction sendError(res: http.ServerResponse, status: number, error: string): void {\n // A body that blew the cap is not read further; close the connection rather\n // than let the rest of it be reinterpreted as a next request.\n sendJson(res, status, { error }, status === 413 ? { connection: 'close' } : {});\n}\n\n// Header only: a token in the query string would land in history and logs.\nfunction presentsCapability(req: http.IncomingMessage, capability: string): boolean {\n const header = req.headers.authorization;\n if (header === undefined) return false;\n const space = header.indexOf(' ');\n if (space === -1) return false;\n if (header.slice(0, space).toLowerCase() !== CAPABILITY_SCHEME.toLowerCase()) return false;\n return capabilityMatches(capability, header.slice(space + 1).trim());\n}\n\nfunction sendUnauthorized(res: http.ServerResponse): void {\n sendJson(res, 401, { error: 'unauthorized' }, { 'www-authenticate': CAPABILITY_SCHEME });\n}\n\nconst REVIEWED_PATH_ERROR = 'path must name a file in the reviewed diff';\n\n/** Core's authorization; answers 400 and returns false when `filePath` is not a reviewed path. */\nfunction requireReviewedPath(ctx: RouteContext, filePath: string, what = 'path'): boolean {\n if (authorizeReviewedPath(ctx.session, filePath).ok) return true;\n sendError(\n ctx.res,\n 400,\n what === 'path' ? REVIEWED_PATH_ERROR : `${what} must name a file in the reviewed diff`\n );\n return false;\n}\n\nfunction requireReviewedQueryPath(ctx: RouteContext): string | null {\n const raw = ctx.url.searchParams.get('path');\n if (raw === null) {\n sendError(ctx.res, 400, REVIEWED_PATH_ERROR);\n return null;\n }\n return requireReviewedPath(ctx, raw) ? raw : null;\n}\n\ntype BodyResult = { ok: true; value: unknown } | { ok: false; status: number; error: string };\n\n/**\n * The declared length is checked before a byte is read and the running total\n * during it, so a chunked body without a length is capped too.\n */\nfunction readJsonBody(req: http.IncomingMessage, maxBytes: number): Promise<BodyResult> {\n const contentType = req.headers['content-type'] ?? '';\n if (!contentType.toLowerCase().startsWith('application/json')) {\n return Promise.resolve({\n ok: false,\n status: 415,\n error: 'content-type must be application/json',\n });\n }\n const declared = Number(req.headers['content-length']);\n if (Number.isFinite(declared) && declared > maxBytes) {\n return Promise.resolve({ ok: false, status: 413, error: 'request body too large' });\n }\n\n return new Promise(resolve => {\n const chunks: Buffer[] = [];\n let received = 0;\n req.on('data', (chunk: Buffer) => {\n received += chunk.length;\n if (received > maxBytes) {\n chunks.length = 0;\n req.removeAllListeners('data');\n req.removeAllListeners('end');\n resolve({ ok: false, status: 413, error: 'request body too large' });\n return;\n }\n chunks.push(chunk);\n });\n req.on('end', () => {\n try {\n resolve({ ok: true, value: JSON.parse(Buffer.concat(chunks).toString('utf-8')) });\n } catch {\n resolve({ ok: false, status: 400, error: 'body must be valid JSON' });\n }\n });\n req.on('error', () => {\n resolve({ ok: false, status: 400, error: 'request body could not be read' });\n });\n });\n}\n\n// Each route validates, calls exactly one core function, and sends its result.\n\nconst routes: Record<string, RouteHandler> = {\n 'GET /api/diff': async ({ res, session }) => {\n // The guide rides with the diff, so the client needs no push channel.\n sendJson(res, 200, getDiffLoad(session));\n },\n\n 'GET /api/config': async ({ res, session }) => {\n sendJson(res, 200, getConfigLoad(session));\n },\n\n 'GET /api/resume': async ({ res, session }) => {\n sendJson(res, 200, getResumeLoad(session));\n },\n\n 'GET /api/file': async ctx => {\n const filePath = requireReviewedQueryPath(ctx);\n if (filePath === null) return;\n // Diff paths are source-relative strings; core matches on them as sent.\n sendJson(ctx.res, 200, getFileHunks(ctx.session, filePath));\n },\n\n 'GET /api/image': async ctx => {\n const filePath = requireReviewedQueryPath(ctx);\n if (filePath === null) return;\n // Core reads the reviewed snapshot under the same identity it just authorized.\n sendJson(ctx.res, 200, await loadImage(ctx.session, filePath));\n },\n\n 'GET /api/attachment': async ctx => {\n // Not a diff path: a `.self-review-assets/<name>` reference core resolves itself; only its shape is checked here.\n const raw = ctx.url.searchParams.get('path');\n if (raw === null || parseAttachmentReference(raw) === null) {\n sendError(ctx.res, 400, 'path must name a file in the .self-review-assets directory');\n return;\n }\n const result = await readAttachment(ctx.session, raw);\n if (!result.ok) {\n const status =\n result.reason === 'not-authorized' ? 400 : result.reason === 'too-large' ? 413 : 404;\n sendError(ctx.res, status, status === 404 ? 'attachment not found' : result.message);\n return;\n }\n const { res } = ctx;\n res.writeHead(200, {\n 'content-type': 'application/octet-stream',\n 'cache-control': 'no-store',\n ...SECURITY_HEADERS,\n });\n res.end(Buffer.from(result.data));\n },\n\n 'POST /api/expand-context': async ctx => {\n const { req, res, session } = ctx;\n const body = await readJsonBody(req, MAX_EXPAND_CONTEXT_BODY_BYTES);\n if (!body.ok) {\n sendError(res, body.status, body.error);\n return;\n }\n const parsed = parseExpandContextBody(body.value);\n if (!parsed.ok) {\n sendError(res, 400, parsed.error);\n return;\n }\n // Becomes a git pathspec; authorized as a reviewed path, then passed through as sent.\n if (!requireReviewedPath(ctx, parsed.value.filePath, 'filePath')) return;\n sendJson(res, 200, await expandContext(session, parsed.value));\n },\n\n // The one route that rewrites a file in the reviewed tree. Core refuses unless the anchored lines still\n // match the suggestion's recorded original byte for byte, and resolves the destination itself.\n 'POST /api/apply-suggestion': async ctx => {\n const { req, res, session } = ctx;\n const body = await readJsonBody(req, MAX_EXPAND_CONTEXT_BODY_BYTES);\n if (!body.ok) {\n sendError(res, body.status, body.error);\n return;\n }\n const parsed = parseSuggestionApplyBody(body.value);\n if (!parsed.ok) {\n sendError(res, 400, parsed.error);\n return;\n }\n if (!requireReviewedPath(ctx, parsed.value.filePath, 'filePath')) return;\n sendJson(res, 200, applySuggestionForSession(session, parsed.value));\n },\n\n // The completion: a 200 means the file is on disk; a failure leaves the server up for a retry.\n 'POST /api/review': async ({ req, res, session, output }) => {\n const body = await readJsonBody(req, MAX_REVIEW_BODY_BYTES);\n if (!body.ok) {\n sendError(res, body.status, body.error);\n return;\n }\n const parsed = parseReviewStateBody(body.value);\n if (!parsed.ok) {\n sendError(res, 400, parsed.error);\n return;\n }\n submitReviewState(session, parsed.value);\n const outcome = await publishSubmittedReview(parsed.value, output, session);\n if (outcome.ok) {\n sendJson(res, 200, outcome);\n } else {\n sendJson(res, publishFailureStatus(outcome.code), outcome);\n }\n },\n};\n\n// Publisher failures are returned, not thrown, so the route answers and keeps serving.\nasync function publishSubmittedReview(\n state: ReviewState,\n output: ReviewOutputTarget,\n session: ReviewSession\n): Promise<ReviewSubmitAck | ReviewSubmitFailure> {\n const options = publishOptionsFor(output, session.attachmentOrigins);\n try {\n const { outputPath } = await publishReview(state, output.path, options);\n console.error(`[serve] Review written to ${outputPath}`);\n return { ok: true, outputPath };\n } catch (error) {\n if (!(error instanceof ReviewPublishError)) throw error;\n console.error(`[serve] Review not saved (${error.code}): ${error.message}`);\n for (const detail of error.details) {\n console.error(`[serve] ${detail}`);\n }\n console.error(\n '[serve] The review is still open in the browser. Fix the problem and press Finish Review again.'\n );\n return { ok: false, code: error.code, message: error.message, details: [...error.details] };\n }\n}\n\nconst DOCUMENT_ERROR_CODES: ReadonlySet<ReviewPublishErrorCode> = new Set([\n 'validation-failed',\n 'xml-illegal-character',\n]);\n\nfunction publishFailureStatus(code: ReviewPublishErrorCode): number {\n return DOCUMENT_ERROR_CODES.has(code) ? 422 : 500;\n}\n\nconst ROUTE_PATHS = new Set(Object.keys(routes).map(key => key.split(' ')[1]));\n\n/**\n * `/` is index.html; everything else is contained under the client directory.\n * Anything that is not a regular file under it is a 404.\n */\nasync function serveStatic(\n res: http.ServerResponse,\n clientDir: string,\n pathname: string\n): Promise<void> {\n let decoded: string;\n try {\n decoded = decodeURIComponent(pathname);\n } catch {\n sendError(res, 404, 'not found');\n return;\n }\n const relative = decoded === '/' ? 'index.html' : decoded.replace(/^\\/+/, '');\n const resolved = containPath(clientDir, relative);\n if (resolved === null) {\n sendError(res, 404, 'not found');\n return;\n }\n\n let data: Buffer;\n try {\n const stat = await fs.promises.stat(resolved);\n if (!stat.isFile()) {\n sendError(res, 404, 'not found');\n return;\n }\n data = await fs.promises.readFile(resolved);\n } catch {\n sendError(res, 404, 'not found');\n return;\n }\n res.writeHead(200, {\n 'content-type':\n CONTENT_TYPES[path.extname(resolved).toLowerCase()] ?? 'application/octet-stream',\n 'content-length': data.length,\n ...SECURITY_HEADERS,\n });\n res.end(data);\n}\n\n/**\n * Taking the session explicitly rather than reading module state mirrors the\n * core handlers and lets a test drive this without a repository. Not yet\n * listening: bind it with `listenLoopback`.\n */\nexport function createReviewServer(options: ReviewServerOptions): http.Server {\n const { session, output, capability, clientDir = defaultClientDir() } = options;\n\n return http.createServer(async (req, res) => {\n const method = req.method ?? 'GET';\n let url: URL;\n try {\n url = new URL(req.url ?? '/', 'http://localhost');\n } catch {\n sendError(res, 400, 'malformed request URL');\n return;\n }\n\n // Before anything is routed: this listener answers only to itself.\n if (!hostIsLoopback(req) || !originMatchesHost(req) || !fetchSiteIsSelf(req)) {\n sendError(res, 403, 'forbidden');\n return;\n }\n\n // Assets are served to anyone; every /api/ route is refused before lookup, so the route table does not leak.\n if (url.pathname.startsWith('/api/') && !presentsCapability(req, capability)) {\n sendUnauthorized(res);\n return;\n }\n\n try {\n const handler = routes[`${method} ${url.pathname}`];\n if (handler) {\n await handler({ req, res, url, session, output });\n } else if (ROUTE_PATHS.has(url.pathname)) {\n sendError(res, 405, 'method not allowed');\n } else if (url.pathname.startsWith('/api/')) {\n sendError(res, 404, 'not found');\n } else if (method === 'GET') {\n await serveStatic(res, clientDir, url.pathname);\n } else {\n sendError(res, 404, 'not found');\n }\n } catch (error) {\n console.error(`[serve] ${method} ${url.pathname} failed:`, error);\n if (!res.headersSent) {\n sendError(res, 500, 'internal error');\n } else {\n res.end();\n }\n }\n });\n}\n\n/**\n * The address is fixed here, not left to the caller: never `0.0.0.0`, never the\n * default. Port 0 asks the OS for an ephemeral one.\n */\nexport function listenLoopback(\n server: http.Server,\n port = 0\n): Promise<{ port: number; url: string }> {\n return new Promise((resolve, reject) => {\n server.once('error', reject);\n server.listen(port, '127.0.0.1', () => {\n server.off('error', reject);\n const address = server.address() as AddressInfo;\n resolve({ port: address.port, url: `http://127.0.0.1:${address.port}/` });\n });\n });\n}\n","// Request validation for the serve package. Core's handlers assume a caller the\n// compiler checked; over HTTP the body is whatever the socket delivered.\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type { ExpandContextRequest, ReviewState, SuggestionApplyRequest } from '@self-review/core';\n\n/** Realpath the deepest existing ancestor, so a deleted file still resolves. */\nfunction realpathDeepestExisting(absolute: string): string | null {\n const missing: string[] = [];\n let current = absolute;\n for (;;) {\n try {\n const real = fs.realpathSync(current);\n return missing.length === 0 ? real : path.join(real, ...missing);\n } catch {\n const parent = path.dirname(current);\n if (parent === current) {\n return null;\n }\n missing.unshift(path.basename(current));\n current = parent;\n }\n }\n}\n\n/**\n * Resolve `candidate` under `root`, or null if it escapes. For the client bundle and attachments only;\n * reviewed diff paths go through core's `authorizeReviewedPath`.\n *\n * Never decode here: callers pass a value `searchParams` already decoded once,\n * and decoding again turns `%2E%2E%2F` inside a filename into a real traversal.\n */\nexport function containPath(root: string, candidate: string): string | null {\n let resolvedRoot: string;\n try {\n resolvedRoot = fs.realpathSync(root);\n } catch {\n return null;\n }\n\n // Realpath both sides so a symlink inside the repository cannot escape it.\n const resolved = realpathDeepestExisting(path.resolve(resolvedRoot, candidate));\n if (resolved === null) {\n return null;\n }\n\n if (resolved === resolvedRoot) {\n return resolved;\n }\n // Root plus separator, not a bare prefix: `/repo-evil` is not under `/repo`.\n const rootWithSep = resolvedRoot.endsWith(path.sep) ? resolvedRoot : resolvedRoot + path.sep;\n return resolved.startsWith(rootWithSep) ? resolved : null;\n}\n\n/**\n * Reaches git as `-U${contextLines}`, so it must be bounded. Matches\n * `MAX_CONTEXT` in useExpandContext.ts; keep the two in step.\n */\nexport const MAX_CONTEXT_LINES = 99_999;\n\nexport type ParseResult<T> = { ok: true; value: T } | { ok: false; error: string };\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nconst EXPAND_CONTEXT_KEYS: ReadonlySet<string> = new Set(['filePath', 'contextLines']);\n\n/**\n * Accepts exactly `{ filePath, contextLines }`. Unknown keys are rejected, not\n * ignored. The route authorizes `filePath` as a reviewed path before git sees it.\n */\nexport function parseExpandContextBody(body: unknown): ParseResult<ExpandContextRequest> {\n if (typeof body !== 'object' || body === null || Array.isArray(body)) {\n return { ok: false, error: 'body must be a JSON object' };\n }\n const record = body as Record<string, unknown>;\n\n for (const key of Object.keys(record)) {\n if (!EXPAND_CONTEXT_KEYS.has(key)) {\n return { ok: false, error: `unknown field: ${key}` };\n }\n }\n\n const { filePath, contextLines } = record;\n if (typeof filePath !== 'string') {\n return { ok: false, error: 'filePath must be a string' };\n }\n if (\n typeof contextLines !== 'number' ||\n !Number.isInteger(contextLines) ||\n contextLines < 0 ||\n contextLines > MAX_CONTEXT_LINES\n ) {\n return {\n ok: false,\n error: `contextLines must be an integer between 0 and ${MAX_CONTEXT_LINES}`,\n };\n }\n\n return { ok: true, value: { filePath, contextLines } };\n}\n\nconst APPLY_KEYS: ReadonlySet<string> = new Set(['filePath', 'lineRange', 'suggestion']);\nconst LINE_RANGE_KEYS: ReadonlySet<string> = new Set(['side', 'start', 'end']);\nconst SUGGESTION_KEYS: ReadonlySet<string> = new Set(['originalCode', 'proposedCode']);\n\n/**\n * Validate the body of `POST /api/apply-suggestion`.\n *\n * This is the one route that rewrites a file in the reviewed tree, so the shape\n * is checked exactly rather than deferred. Core refuses anything whose anchored\n * lines do not still match `originalCode` byte for byte, but it should never be\n * asked a question this malformed in the first place.\n */\nexport function parseSuggestionApplyBody(body: unknown): ParseResult<SuggestionApplyRequest> {\n if (!isRecord(body)) {\n return { ok: false, error: 'body must be a JSON object' };\n }\n for (const key of Object.keys(body)) {\n if (!APPLY_KEYS.has(key)) return { ok: false, error: `unknown field: ${key}` };\n }\n\n const { filePath, lineRange, suggestion } = body;\n if (typeof filePath !== 'string' || filePath === '') {\n return { ok: false, error: 'filePath must be a non-empty string' };\n }\n\n // A file-level comment has no anchor, and core refuses it. Accept the null so\n // the refusal comes back in core's vocabulary rather than as a 400.\n if (lineRange !== null) {\n if (!isRecord(lineRange)) {\n return { ok: false, error: 'lineRange must be an object or null' };\n }\n for (const key of Object.keys(lineRange)) {\n if (!LINE_RANGE_KEYS.has(key)) {\n return { ok: false, error: `unknown lineRange field: ${key}` };\n }\n }\n if (lineRange.side !== 'old' && lineRange.side !== 'new') {\n return { ok: false, error: \"lineRange.side must be 'old' or 'new'\" };\n }\n for (const key of ['start', 'end'] as const) {\n const value = lineRange[key];\n if (typeof value !== 'number' || !Number.isInteger(value) || value < 1) {\n return { ok: false, error: `lineRange.${key} must be a positive integer` };\n }\n }\n if ((lineRange.end as number) < (lineRange.start as number)) {\n return { ok: false, error: 'lineRange.end must not precede lineRange.start' };\n }\n }\n\n if (!isRecord(suggestion)) {\n return { ok: false, error: 'suggestion must be an object' };\n }\n for (const key of Object.keys(suggestion)) {\n if (!SUGGESTION_KEYS.has(key)) {\n return { ok: false, error: `unknown suggestion field: ${key}` };\n }\n }\n for (const key of ['originalCode', 'proposedCode'] as const) {\n if (typeof suggestion[key] !== 'string') {\n return { ok: false, error: `suggestion.${key} must be a string` };\n }\n }\n\n return { ok: true, value: body as unknown as SuggestionApplyRequest };\n}\n\nconst REVIEW_STATE_KEYS: ReadonlySet<string> = new Set(['timestamp', 'source', 'files']);\n\n/**\n * Accepts exactly `{ timestamp, source, files }`. Remote provenance is never\n * taken from the client; the process injects it after submission.\n *\n * Structural only — the XSD checks nested fields at serialization time. The\n * exception is `id`, checked below, because the serializer turns an id into a\n * file name *before* it validates anything.\n */\nexport function parseReviewStateBody(body: unknown): ParseResult<ReviewState> {\n if (typeof body !== 'object' || body === null || Array.isArray(body)) {\n return { ok: false, error: 'body must be a JSON object' };\n }\n const record = body as Record<string, unknown>;\n\n for (const key of Object.keys(record)) {\n if (!REVIEW_STATE_KEYS.has(key)) {\n return { ok: false, error: `unknown field: ${key}` };\n }\n }\n\n const { timestamp, source, files } = record;\n if (typeof timestamp !== 'string') {\n return { ok: false, error: 'timestamp must be a string' };\n }\n if (typeof source !== 'object' || source === null || Array.isArray(source)) {\n return { ok: false, error: 'source must be an object' };\n }\n if (!Array.isArray(files)) {\n return { ok: false, error: 'files must be an array' };\n }\n\n const decoded = decodeFileAttachments(files);\n if (!decoded.ok) {\n return decoded;\n }\n\n return { ok: true, value: { timestamp, source, files: decoded.value } as ReviewState };\n}\n\n// Attachment blobs on the wire. `JSON.stringify` renders an ArrayBuffer as\n// `{}`, which would write a zero-byte image with a 200 and no error anywhere,\n// so the client sends base64 in `dataBase64` and a raw `data` field is refused.\n\n/** Canonical base64: full quartets, with at most one padded tail group. */\nconst BASE64_PATTERN =\n /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)$/;\n\nconst RAW_DATA_ERROR =\n 'attachment data must be sent base64-encoded as dataBase64, never as a serialized ArrayBuffer';\n\n/** Every id this app makes: a randomUUID, or generateId's `${ms}-${base36}`. */\nconst ID_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;\n\n/**\n * An id becomes an attachment's file name, so `../../x` was a path. Core\n * contains that write too; refusing here fails with a 400 at the door rather\n * than midway through saving, once the review has left the session.\n */\nfunction checkId(entry: Record<string, unknown>, what: string): string | null {\n if (entry.id === undefined) return null;\n if (typeof entry.id !== 'string' || !ID_PATTERN.test(entry.id)) {\n return `${what} id must match ${ID_PATTERN.source}`;\n }\n return null;\n}\n\n/**\n * The slice is load-bearing: `Buffer.from` returns a view into Node's shared\n * pool, so handing `.buffer` over whole writes unrelated memory to disk.\n */\nfunction base64ToArrayBuffer(value: string): ArrayBuffer {\n const buffer = Buffer.from(value, 'base64');\n return buffer.buffer.slice(\n buffer.byteOffset,\n buffer.byteOffset + buffer.byteLength\n ) as ArrayBuffer;\n}\n\n/** Decode each blob. A resumed attachment carries none and passes through. */\nfunction decodeAttachmentList(list: unknown[]): ParseResult<unknown[]> {\n const decoded: unknown[] = [];\n for (const entry of list) {\n if (!isRecord(entry)) {\n decoded.push(entry);\n continue;\n }\n if (entry.data !== undefined) {\n return { ok: false, error: RAW_DATA_ERROR };\n }\n if (entry.dataBase64 === undefined) {\n decoded.push(entry);\n continue;\n }\n const encoded = entry.dataBase64;\n if (typeof encoded !== 'string' || !BASE64_PATTERN.test(encoded)) {\n // The empty string fails the pattern too: an attachment with no bytes\n // is a zero-byte file on disk, which is the failure being guarded.\n return { ok: false, error: 'attachment dataBase64 must be non-empty base64' };\n }\n const { dataBase64: _encoded, ...rest } = entry;\n decoded.push({ ...rest, data: base64ToArrayBuffer(encoded) });\n }\n return { ok: true, value: decoded };\n}\n\n/**\n * Walk the files, decoding blobs and checking every id that becomes a file\n * name. Tolerant of anything it does not recognise, since the XSD checks the\n * document later; strict about the encoding, which the XSD cannot see.\n */\nfunction decodeFileAttachments(files: unknown[]): ParseResult<unknown[]> {\n const decodedFiles: unknown[] = [];\n for (const file of files) {\n if (!isRecord(file) || !Array.isArray(file.comments)) {\n decodedFiles.push(file);\n continue;\n }\n const decodedComments: unknown[] = [];\n for (const comment of file.comments) {\n if (!isRecord(comment)) {\n decodedComments.push(comment);\n continue;\n }\n const commentIdError = checkId(comment, 'comment');\n if (commentIdError) return { ok: false, error: commentIdError };\n const next: Record<string, unknown> = { ...comment };\n\n if (Array.isArray(comment.attachments)) {\n const result = decodeAttachmentList(comment.attachments);\n if (!result.ok) return result;\n next.attachments = result.value;\n }\n\n if (Array.isArray(comment.replies)) {\n const decodedReplies: unknown[] = [];\n for (const reply of comment.replies) {\n if (!isRecord(reply)) {\n decodedReplies.push(reply);\n continue;\n }\n const replyIdError = checkId(reply, 'reply');\n if (replyIdError) return { ok: false, error: replyIdError };\n if (!Array.isArray(reply.attachments)) {\n decodedReplies.push(reply);\n continue;\n }\n const result = decodeAttachmentList(reply.attachments);\n if (!result.ok) return result;\n decodedReplies.push({ ...reply, attachments: result.value });\n }\n next.replies = decodedReplies;\n }\n\n decodedComments.push(next);\n }\n decodedFiles.push({ ...file, comments: decodedComments });\n }\n return { ok: true, value: decodedFiles };\n}\n","// The session capability. Host/Origin checks cannot tell the reviewer from another local account\n// (loopback is shared and a local client can send no browser headers); this secret can.\n// The browser side of the contract is in ./protocol.ts.\n\nimport { randomBytes, timingSafeEqual } from 'node:crypto';\n\nexport function generateCapability(): string {\n return randomBytes(32).toString('base64url');\n}\n\n// Constant-time once lengths agree; every capability has the same length, so the length check leaks nothing.\nexport function capabilityMatches(expected: string, presented: string): boolean {\n const a = Buffer.from(expected, 'utf-8');\n const b = Buffer.from(presented, 'utf-8');\n return a.length === b.length && timingSafeEqual(a, b);\n}\n","// The HTTP contract both ends share; no Node dependency so the browser bundle can import it.\n\nimport type { ReviewPublishErrorCode } from '@self-review/core';\n\n/**\n * Upper bound on a `POST /api/review` body. The client checks it too, so an oversized review is\n * refused with the work still in the page. Attachments ride base64, about 4/3 of their bytes.\n */\nexport const MAX_REVIEW_BODY_BYTES = 32 * 1024 * 1024;\n\n/** A 200 from `POST /api/review`, sent only after the document is published. */\nexport interface ReviewSubmitAck {\n ok: true;\n /** The absolute path the review was written to. */\n outputPath: string;\n}\n\n/** `POST /api/review` when publishing failed; the server stays up for a retry. */\nexport interface ReviewSubmitFailure {\n ok: false;\n /** The publisher's code; `details` has one rendered line per problem. */\n code: ReviewPublishErrorCode;\n message: string;\n details: string[];\n}\n\n/** The client's own code for a body it refused to send, and for the server's 413. */\nexport const REVIEW_TOO_LARGE_CODE = 'review-too-large';\n\n// The capability travels only in the launch URL's fragment (`/#cap=<token>`), which a browser never sends\n// (not even in `Referer`). The page moves it into `Authorization: Bearer` on every API request.\nexport const CAPABILITY_FRAGMENT_KEY = 'cap';\n\nexport const CAPABILITY_SCHEME = 'Bearer';\n\nexport function formatLaunchUrl(listenerUrl: string, capability: string): string {\n return `${listenerUrl}#${CAPABILITY_FRAGMENT_KEY}=${capability}`;\n}\n\n// Parsed as URL parameters so a browser that re-encodes the fragment is still read.\nexport function parseCapabilityFragment(hash: string): string | null {\n const params = new URLSearchParams(hash.startsWith('#') ? hash.slice(1) : hash);\n const value = params.get(CAPABILITY_FRAGMENT_KEY);\n return value ? value : null;\n}\n\nexport function capabilityAuthorization(capability: string): string {\n return `${CAPABILITY_SCHEME} ${capability}`;\n}\n\nexport function formatMegabytes(bytes: number): string {\n return (bytes / (1024 * 1024)).toFixed(1);\n}\n"],"mappings":";;;AAWA,SAAS,qBAAqB;;;ACT9B,SAAS,iCAAiC;AAgB1C,IAAM,cAAc;AAAA,EAClB,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,iBAAiB;AACnB;AAEA,IAAM,gBAAgB;AAAA,EACpB,UAAU;AAAA,EACV,MAAM;AAAA,EACN,aAAa;AAAA,EACb,MAAM;AACR;AAIO,SAAS,eAAe,MAA2B;AACxD,QAAM,EAAE,QAAQ,OAAO,KAAK,IAAI,0BAA0B,MAAM;AAAA,IAC9D,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AACD,SAAO;AAAA,IACL,aAAa;AAAA,IACb,YAAY,OAAO;AAAA,IACnB,YAAY,OAAO;AAAA,IACnB,MAAM,MAAM;AAAA,IACZ,SAAS,MAAM;AAAA,EACjB;AACF;;;AClCA,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAWP,IAAM,MAAM,CAAC,YAAoB,QAAQ,MAAM,WAAW,OAAO,EAAE;AAGnE,eAAsB,eAAe,MAAwC;AAE3E,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,eAAe,yBAAyB,EAAE,IAAI,CAAC;AACrD,QAAM,SAAS,oBAAoB,KAAK,YAAY,cAAc,GAAG;AAErE,QAAM,UAAU,kBAAkB,OAAO,MAAM,kBAAkB,MAAM,CAAC;AACxE,MAAI,SAAS;AACX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BAA0B;AAC3F,UAAQ;AAAA,IACN;AAAA,EAEF;AACF;AAEA,KAAK,EAAE,MAAM,WAAS;AACpB,UAAQ,MAAM,WAAW,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AACjF,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["fs","path","publishOptionsFor","resolve","publishOptionsFor"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as p,r as u,d as a}from"./chunk-SVP7TREG-BXZpN96Q.js";import{p as f}from"./chunk-JWPE2WC7-BHqPUvha.js";import{_ as n,l as o}from"./mermaid.core-B9m3791z.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-JBAmnTQp.js";import"./index-vUb9LsiF.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a0 as ln,a1 as an,a2 as H,a3 as q,a4 as B,a5 as un,a6 as y,a7 as tn,a8 as L,a9 as _,aa as rn,ab as o,ac as on,ad as sn,ae as fn}from"./mermaid.core-
|
|
1
|
+
import{a0 as ln,a1 as an,a2 as H,a3 as q,a4 as B,a5 as un,a6 as y,a7 as tn,a8 as L,a9 as _,aa as rn,ab as o,ac as on,ad as sn,ae as fn}from"./mermaid.core-B9m3791z.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,C,a){var O=I-l,i=D-h,n=C-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function W(l,h,I,D,v,A,C){var a=l-I,O=h-D,i=(C?A:-A)/L(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,F=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*L(on(0,T*T*R-P*P)),j=(P*g-m*S)/R,z=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=j-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(j=w,z=p),{cx:j,cy:z,x01:-n,y01:-d,x11:j*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=yn,I=B(0),D=null,v=gn,A=dn,C=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,F=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(F>tn-y)a.moveTo(s*H(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*H(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=F,S=F,j=C.apply(this,arguments)/2,z=j>y&&(D?+D.apply(this,arguments):L(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(z>y){var G=sn(z/u*q(j)),M=sn(z/s*q(j));(P-=G*2)>y?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(S-=M*2)>y?(M*=t?1:-1,m+=M,g-=M):(S=0,m=g=(f+c)/2)}var J=s*H(m),K=s*q(m),N=u*H(T),Q=u*q(T);if(w>y){var U=s*H(g),V=s*q(g),X=u*H(R),Y=u*q(R),E;if(F<an)if(E=pn(J,K,X,Y,U,V,N,Q)){var Z=J-E[0],$=K-E[1],b=U-E[0],k=V-E[1],nn=1/q(fn((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=W(X,Y,J,K,s,x,t),r=W(U,V,N,Q,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(J,K),a.arc(0,0,s,m,g,!t)):a.moveTo(J,K),!(u>y)||!(P>y)?a.lineTo(N,Q):p>y?(e=W(N,Q,U,V,u,-p,t),r=W(J,K,X,Y,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[H(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:B(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:B(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:B(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:B(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:B(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:B(+n),i):A},i.padAngle=function(n){return arguments.length?(C=typeof n=="function"?n:B(+n),i):C},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|