local-diff-reviewer 1.0.0 → 1.0.4
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 +28 -55
- package/SKILL.md +2 -2
- package/dist/cli/start.js +21 -5
- package/dist/web/assets/{arc-CR7lDgfr.js → arc-DfZYUaz4.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-B-Kf98tI.js → architectureDiagram-3BPJPVTR-Un1C7dX5.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-C6G2D8zB.js → blockDiagram-GPEHLZMM-DoE66LOm.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-B8Z0vFGi.js → c4Diagram-AAUBKEIU-Ch17mKwl.js} +1 -1
- package/dist/web/assets/channel-tS6_tEZH.js +1 -0
- package/dist/web/assets/{chunk-2J33WTMH-BJYcz9p6.js → chunk-2J33WTMH-DsTTzQ06.js} +1 -1
- package/dist/web/assets/{chunk-3OPIFGDE-CadWbiuZ.js → chunk-3OPIFGDE-C4BFnYAe.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-p5TBPKfa.js → chunk-4BX2VUAB-CBYOekG6.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-Cd7Tpfqt.js → chunk-55IACEB6-bkX7IfWj.js} +1 -1
- package/dist/web/assets/{chunk-5ZQYHXKU-rVi82pOk.js → chunk-5ZQYHXKU-DmYX07rl.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-DCK60o1J.js → chunk-727SXJPM-myW6yB1O.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-DsaTBCmF.js → chunk-AQP2D5EJ-fa_HpDkc.js} +1 -1
- package/dist/web/assets/{chunk-BSJP7CBP-Bhh_dCA1.js → chunk-BSJP7CBP-NpOkPl8K.js} +1 -1
- package/dist/web/assets/{chunk-CSCIHK7Q-BTxAxDrY.js → chunk-CSCIHK7Q-jWMYsJiR.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-DlFkGqeu.js → chunk-FMBD7UC4-BuB89xp8.js} +1 -1
- package/dist/web/assets/{chunk-KSCS5N6A-BYPjHZNn.js → chunk-KSCS5N6A-BvSsBz45.js} +1 -1
- package/dist/web/assets/{chunk-L5ZTLDWV-BMFnPCzP.js → chunk-L5ZTLDWV-Cslvwh3t.js} +1 -1
- package/dist/web/assets/{chunk-LZXEDZCA-BKhHYjKh.js → chunk-LZXEDZCA-lDGN1tUz.js} +2 -2
- package/dist/web/assets/{chunk-ND2GUHAM-7KRXvqPH.js → chunk-ND2GUHAM-DGtWurFf.js} +1 -1
- package/dist/web/assets/{chunk-NZK2D7GU-C2gmfVLG.js → chunk-NZK2D7GU-BhN9qm2L.js} +1 -1
- package/dist/web/assets/{chunk-O5CBEL6O-BDgBHpRo.js → chunk-O5CBEL6O-DPNhEfdl.js} +1 -1
- package/dist/web/assets/chunk-QZHKN3VN-MdvGD9q1.js +1 -0
- package/dist/web/assets/chunk-WU5MYG2G-Cot-8ei2.js +1 -0
- package/dist/web/assets/{chunk-XPW4576I-CNcwF46w.js → chunk-XPW4576I-BRb6pBFA.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-Ba9dn90z.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-AkPgLlFm.js +1 -0
- package/dist/web/assets/{cose-bilkent-S5V4N54A-DGxrNo18.js → cose-bilkent-S5V4N54A-DP7aCqjn.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-DgS2nVEP.js → dagre-BM42HDAG-DW8OoOF9.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-CZ3HTlHq.js → diagram-2AECGRRQ-Dhr52Lcq.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-Q7ELSmIM.js → diagram-5GNKFQAL-00RS5q-p.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-E5adO5kX.js → diagram-KO2AKTUF-CV1YsijI.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-DckjoLmV.js → diagram-LMA3HP47-Cu6hlhhL.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-C6IV8tgf.js → diagram-OG6HWLK6-f8Aglkk5.js} +1 -1
- package/dist/web/assets/{dist-BBL8i-qs.js → dist-BbvzfnQH.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-CtdFt0tH.js → erDiagram-TEJ5UH35-BOpwL6Hq.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-Cj3R7yTy.js → flowDiagram-I6XJVG4X-JpfaqfMd.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-Bb6ylSyS.js → ganttDiagram-6RSMTGT7-_07N56My.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DJHSJ07v.js → gitGraphDiagram-PVQCEYII-CW2hqk_8.js} +1 -1
- package/dist/web/assets/{index-Byh7XaFy.js → index-CxFV1WHQ.js} +2 -2
- package/dist/web/assets/{infoDiagram-5YYISTIA-1xrP_FxB.js → infoDiagram-5YYISTIA-B35H3DgZ.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-DxyBX-lT.js → ishikawaDiagram-YF4QCWOH-DxVWMRSB.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW-DMcyhQOZ.js → journeyDiagram-JHISSGLW-C__VorSx.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-qZQpCEuA.js → kanban-definition-UN3LZRKU-BKSCqg5P.js} +1 -1
- package/dist/web/assets/{line-BJ3a5kXp.js → line-SFaTyCgO.js} +1 -1
- package/dist/web/assets/{linear-WojM0Myz.js → linear-CCDSib_A.js} +1 -1
- package/dist/web/assets/{mermaid-parser.core-CXQdsx5L.js → mermaid-parser.core-B4q5D_X_.js} +1 -1
- package/dist/web/assets/{mermaid.core-D-XPCWky.js → mermaid.core-DiPBDfaO.js} +3 -3
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-B3OxgBPA.js → mindmap-definition-RKZ34NQL-BJZedUBK.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-Div1l6Q1.js → pieDiagram-4H26LBE5-DtkdCUA9.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-CeXbRhNe.js → quadrantDiagram-W4KKPZXB-Cks8DI1_.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-BlGgeVCv.js → requirementDiagram-4Y6WPE33-DIJqz1Ht.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-BhwjPB4q.js → sankeyDiagram-5OEKKPKP-waqn6y15.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-DNHlWYtx.js → sequenceDiagram-3UESZ5HK-Cyzxtc0o.js} +1 -1
- package/dist/web/assets/{src-Bn2XKj5Y.js → src-DboPYYAM.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-CdZgtb-A.js → stateDiagram-AJRCARHV-BIfp7CSY.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-CBvj4HDj.js +1 -0
- package/dist/web/assets/{timeline-definition-PNZ67QCA-Ch-1WuO4.js → timeline-definition-PNZ67QCA-5e-cw7ns.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-BU0olyYI.js → vennDiagram-CIIHVFJN-H4TiL4fv.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-DXFmQa94.js → wardleyDiagram-YWT4CUSO-C9je1Qmh.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-BY6dYn-A.js → xychartDiagram-2RQKCTM6-CbnF4TLC.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +17 -3
- package/dist/web/assets/channel-BLQGEX2L.js +0 -1
- package/dist/web/assets/chunk-QZHKN3VN-BGdvirFT.js +0 -1
- package/dist/web/assets/chunk-WU5MYG2G-VXAyXnrB.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-DGbdorsF.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-CdJT8iZ_.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-C5vqR8l5.js +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# diff-review
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
AI chat 里的本地代码审查工具。可以直接用 CLI 打开,也可以安装成 agent skill。
|
|
4
6
|
|
|
5
7
|
## Quick Start
|
|
@@ -7,7 +9,7 @@ AI chat 里的本地代码审查工具。可以直接用 CLI 打开,也可以
|
|
|
7
9
|
Try it first:
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
|
-
npx local-diff-reviewer
|
|
12
|
+
npx --yes local-diff-reviewer
|
|
11
13
|
```
|
|
12
14
|
|
|
13
15
|
Install and use:
|
|
@@ -20,7 +22,7 @@ local-diff-reviewer
|
|
|
20
22
|
Enable use from AI agents:
|
|
21
23
|
|
|
22
24
|
```bash
|
|
23
|
-
npx skills add
|
|
25
|
+
npx skills add Mone-Lee/diff-review
|
|
24
26
|
```
|
|
25
27
|
|
|
26
28
|
## 功能边界
|
|
@@ -34,53 +36,6 @@ npx skills add limengyi/diff-review
|
|
|
34
36
|
- 支持通过内部 `--comment` 参数预置 agent findings / replies。
|
|
35
37
|
- 支持复制极简 AI prompt。
|
|
36
38
|
|
|
37
|
-
## 评论定位原理(新手友好版)
|
|
38
|
-
|
|
39
|
-
很多人会直觉认为:评论只和“第几行”绑定。
|
|
40
|
-
比如删掉第 10 行后,原来第 11 行顶上来变成第 10 行,评论也应该跟着走。
|
|
41
|
-
|
|
42
|
-
这个工具不是这样做的。它用的是“锚点”定位,锚点至少包含:
|
|
43
|
-
|
|
44
|
-
- 文件路径(`filePath`)
|
|
45
|
-
- 行号(`lineNumber`)
|
|
46
|
-
- 行所在版本(`side`:旧版本 `old` / 新版本 `new`,代码 Diff 专用)
|
|
47
|
-
|
|
48
|
-
这意味着评论绑定的是“哪一个版本里的哪一行”,而不是“屏幕上现在第几行”。
|
|
49
|
-
|
|
50
|
-
### 为什么删除内容后评论可能不显示?
|
|
51
|
-
|
|
52
|
-
- 对代码 Diff 行评论:
|
|
53
|
-
- 如果评论当时加在被删除的旧行上,它的锚点是 `old + 行号`。
|
|
54
|
-
- 删除后右侧展示的是新版本内容(`new`),`old` 锚点找不到对应渲染位置时,就不会显示在行内。
|
|
55
|
-
- 对 Markdown 行评论:
|
|
56
|
-
- 评论绑定的是 source line(源文件行号)。
|
|
57
|
-
- 被评论的那段 Markdown 真被删掉后,预览里没有对应块可挂载,行内自然不显示。
|
|
58
|
-
|
|
59
|
-
### 一个非常短的例子
|
|
60
|
-
|
|
61
|
-
1. 你在 `old` 版本第 20 行加了评论。
|
|
62
|
-
2. 后续改动把第 20 行删除,并让后面内容上移。
|
|
63
|
-
3. 新内容虽然“占了第 20 行的位置”,但它属于 `new` 版本,不是原来的 `old` 行。
|
|
64
|
-
4. 所以系统不会把旧评论自动贴到新内容上。
|
|
65
|
-
|
|
66
|
-
这样做的好处是:避免评论“串行”到语义完全不同的内容上,减少误导。
|
|
67
|
-
|
|
68
|
-
复制出的 prompt 包含 thread id、定位信息和评论内容。thread id 用于让 agent 后续通过 `--comment '{"type":"reply",...}'` 精确回复原评论:
|
|
69
|
-
|
|
70
|
-
```text
|
|
71
|
-
[thread:<thread-id>]
|
|
72
|
-
文件路径:行号
|
|
73
|
-
评论内容
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
文件级评论不包含行号:
|
|
77
|
-
|
|
78
|
-
```text
|
|
79
|
-
[thread:<thread-id>]
|
|
80
|
-
文件路径
|
|
81
|
-
评论内容
|
|
82
|
-
```
|
|
83
|
-
|
|
84
39
|
## CLI 使用方式
|
|
85
40
|
|
|
86
41
|
```bash
|
|
@@ -108,10 +63,10 @@ local-diff-reviewer HEAD~1 HEAD
|
|
|
108
63
|
安装 skill:
|
|
109
64
|
|
|
110
65
|
```bash
|
|
111
|
-
npx skills add
|
|
66
|
+
npx skills add Mone-Lee/diff-review
|
|
112
67
|
```
|
|
113
68
|
|
|
114
|
-
skill 会从目标 workspace 运行 `npx local-diff-reviewer [args...]`。
|
|
69
|
+
skill 会从目标 workspace 运行 `npx --yes local-diff-reviewer [args...]`。
|
|
115
70
|
|
|
116
71
|
### 预置 agent 评论
|
|
117
72
|
|
|
@@ -120,28 +75,28 @@ CLI 支持重复传入 `--comment <json>`,用于在打开 UI 前把 agent 审
|
|
|
120
75
|
代码 diff 行评论:
|
|
121
76
|
|
|
122
77
|
```bash
|
|
123
|
-
npx local-diff-reviewer \
|
|
78
|
+
npx --yes local-diff-reviewer \
|
|
124
79
|
--comment '{"type":"thread","filePath":"src/foo.ts","position":{"side":"new","line":36},"body":"这里没有处理空数组,可能导致运行时报错。"}'
|
|
125
80
|
```
|
|
126
81
|
|
|
127
82
|
Markdown source line 评论:
|
|
128
83
|
|
|
129
84
|
```bash
|
|
130
|
-
npx local-diff-reviewer \
|
|
85
|
+
npx --yes local-diff-reviewer \
|
|
131
86
|
--comment '{"type":"thread","filePath":"README.md","position":{"type":"markdown","line":22},"body":"这里可以补充 old/new side 的例子。"}'
|
|
132
87
|
```
|
|
133
88
|
|
|
134
89
|
文件级评论:
|
|
135
90
|
|
|
136
91
|
```bash
|
|
137
|
-
npx local-diff-reviewer \
|
|
92
|
+
npx --yes local-diff-reviewer \
|
|
138
93
|
--comment '{"type":"thread","filePath":"src/foo.ts","body":"这个文件的错误处理策略需要统一。"}'
|
|
139
94
|
```
|
|
140
95
|
|
|
141
96
|
回复已有 thread:
|
|
142
97
|
|
|
143
98
|
```bash
|
|
144
|
-
npx local-diff-reviewer \
|
|
99
|
+
npx --yes local-diff-reviewer \
|
|
145
100
|
--comment '{"type":"reply","threadId":"<thread-id>","body":"同意,这里应该按 repoRoot 隔离评论存储。"}'
|
|
146
101
|
```
|
|
147
102
|
|
|
@@ -155,6 +110,24 @@ npx local-diff-reviewer \
|
|
|
155
110
|
- `replied`:已有 agent 内容,或从 resolved 重新打开。
|
|
156
111
|
- `resolved`:用户确认完成后的状态。
|
|
157
112
|
|
|
113
|
+
## 发布流程
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm run release
|
|
117
|
+
npm run release minor
|
|
118
|
+
npm run release major
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
该命令会按顺序执行:
|
|
122
|
+
|
|
123
|
+
- `npm run release:check`
|
|
124
|
+
- `npm version <patch|minor|major>`(默认 `patch`)
|
|
125
|
+
- `npm publish`
|
|
126
|
+
- `git push`
|
|
127
|
+
- `git push --tags`
|
|
128
|
+
|
|
129
|
+
只有在 `npm publish` 成功后,才会自动推送提交和标签到 GitHub。
|
|
130
|
+
|
|
158
131
|
## 本地开发
|
|
159
132
|
|
|
160
133
|
```bash
|
package/SKILL.md
CHANGED
|
@@ -19,13 +19,13 @@ Use this skill when the user asks for `/diff-review`, wants to inspect current w
|
|
|
19
19
|
Do not ask the user to run a shell CLI manually. Run the package command from the workspace root:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
npx local-diff-reviewer [args...]
|
|
22
|
+
npx --yes local-diff-reviewer [args...]
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
When you have concrete review findings or answers to existing review comments, preload them with one `--comment` JSON argument per comment before launching the viewer:
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
npx local-diff-reviewer [args...] \
|
|
28
|
+
npx --yes local-diff-reviewer [args...] \
|
|
29
29
|
--comment '{"type":"thread","filePath":"src/foo.ts","position":{"side":"new","line":36},"body":"Explain the finding in the user language."}' \
|
|
30
30
|
--comment '{"type":"reply","threadId":"existing-thread-id","body":"Answer the existing thread as the agent."}'
|
|
31
31
|
```
|
package/dist/cli/start.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/cli/start.ts
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
import { existsSync as existsSync2 } from "node:fs";
|
|
6
|
-
import { dirname as dirname2, join as join4, resolve } from "node:path";
|
|
6
|
+
import { dirname as dirname2, join as join4, resolve as resolve2 } from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
|
|
9
9
|
// src/server/storage.ts
|
|
@@ -513,7 +513,7 @@ function binaryAddedDiff(path) {
|
|
|
513
513
|
// src/server/index.ts
|
|
514
514
|
import express from "express";
|
|
515
515
|
import { existsSync } from "node:fs";
|
|
516
|
-
import { join as join3 } from "node:path";
|
|
516
|
+
import { join as join3, normalize as normalize2, resolve, sep } from "node:path";
|
|
517
517
|
|
|
518
518
|
// src/core/markdown-source-map.ts
|
|
519
519
|
import GithubSlugger from "github-slugger";
|
|
@@ -649,6 +649,22 @@ async function startServer(state, port = 4966) {
|
|
|
649
649
|
next(error);
|
|
650
650
|
}
|
|
651
651
|
});
|
|
652
|
+
app.get("/api/markdown-asset", (req, res) => {
|
|
653
|
+
const relativePath = String(req.query.path ?? "").trim();
|
|
654
|
+
if (!relativePath) {
|
|
655
|
+
res.status(400).json({ error: "Asset path is required" });
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
const repoRoot = resolve(state.session.repoRoot);
|
|
659
|
+
const normalizedRelativePath = normalize2(relativePath);
|
|
660
|
+
const absolutePath = resolve(repoRoot, normalizedRelativePath);
|
|
661
|
+
const inRepo = absolutePath === repoRoot || absolutePath.startsWith(`${repoRoot}${sep}`);
|
|
662
|
+
if (!inRepo || !existsSync(absolutePath)) {
|
|
663
|
+
res.status(404).json({ error: "Asset not found" });
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
res.sendFile(absolutePath);
|
|
667
|
+
});
|
|
652
668
|
app.get("/api/threads", async (_req, res, next) => {
|
|
653
669
|
try {
|
|
654
670
|
res.json(await readComments(state.session.repoRoot));
|
|
@@ -844,11 +860,11 @@ async function startServer(state, port = 4966) {
|
|
|
844
860
|
app.use((error, _req, res, _next) => {
|
|
845
861
|
res.status(500).json({ error: error.message });
|
|
846
862
|
});
|
|
847
|
-
return new Promise((
|
|
863
|
+
return new Promise((resolve3) => {
|
|
848
864
|
const server = app.listen(port, "127.0.0.1", () => {
|
|
849
865
|
const address = server.address();
|
|
850
866
|
const actualPort = typeof address === "object" && address ? address.port : port;
|
|
851
|
-
|
|
867
|
+
resolve3(`http://127.0.0.1:${actualPort}`);
|
|
852
868
|
});
|
|
853
869
|
});
|
|
854
870
|
}
|
|
@@ -861,7 +877,7 @@ function selectPromptThreads(threads, scope) {
|
|
|
861
877
|
}
|
|
862
878
|
|
|
863
879
|
// src/cli/start.ts
|
|
864
|
-
var packageRoot =
|
|
880
|
+
var packageRoot = resolve2(dirname2(fileURLToPath(import.meta.url)), "../..");
|
|
865
881
|
var builtWebDist = join4(packageRoot, "dist", "web");
|
|
866
882
|
async function main() {
|
|
867
883
|
const { dev, reviewArgs, comments } = parseCliOptions(process.argv.slice(2));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./path-BJQEcSo7.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,u as p}from"./dist-
|
|
1
|
+
import{n as e,t}from"./path-BJQEcSo7.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,u as p}from"./dist-BbvzfnQH.js";function m(e){return e.innerRadius}function h(e){return e.outerRadius}function g(e){return e.startAngle}function _(e){return e.endAngle}function v(e){return e&&e.padAngle}function y(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function b(e,t,n,r,i,a,o){var c=e-n,l=t-r,u=(o?a:-a)/d(c*c+l*l),f=u*l,p=-u*c,m=e+f,h=t+p,g=n+f,_=r+p,v=(m+g)/2,y=(h+_)/2,b=g-m,x=_-h,S=b*b+x*x,C=i-a,w=m*_-g*h,T=(x<0?-1:1)*d(s(0,C*C*S-w*w)),E=(w*x-b*T)/S,D=(-w*b-x*T)/S,O=(w*x+b*T)/S,k=(-w*b+x*T)/S,A=E-v,j=D-y,M=O-v,N=k-y;return A*A+j*j>M*M+N*N&&(E=O,D=k),{cx:E,cy:D,x01:-f,y01:-p,x11:E*(i/C-1),y11:D*(i/C-1)}}function x(){var s=m,x=h,S=e(0),C=null,w=g,T=_,E=v,D=null,O=t(k);function k(){var e,t,m=+s.apply(this,arguments),h=+x.apply(this,arguments),g=w.apply(this,arguments)-r,_=T.apply(this,arguments)-r,v=l(_-g),k=_>g;if(D||=e=O(),h<m&&(t=h,h=m,m=t),!(h>1e-12))D.moveTo(0,0);else if(v>c-1e-12)D.moveTo(h*u(g),h*a(g)),D.arc(0,0,h,g,_,!k),m>1e-12&&(D.moveTo(m*u(_),m*a(_)),D.arc(0,0,m,_,g,k));else{var A=g,j=_,M=g,N=_,P=v,F=v,I=E.apply(this,arguments)/2,L=I>1e-12&&(C?+C.apply(this,arguments):d(m*m+h*h)),R=p(l(h-m)/2,+S.apply(this,arguments)),z=R,B=R,V,H;if(L>1e-12){var U=o(L/m*a(I)),W=o(L/h*a(I));(P-=U*2)>1e-12?(U*=k?1:-1,M+=U,N-=U):(P=0,M=N=(g+_)/2),(F-=W*2)>1e-12?(W*=k?1:-1,A+=W,j-=W):(F=0,A=j=(g+_)/2)}var G=h*u(A),K=h*a(A),q=m*u(N),J=m*a(N);if(R>1e-12){var Y=h*u(j),X=h*a(j),Z=m*u(M),Q=m*a(M),$;if(v<i)if($=y(G,K,Z,Q,Y,X,q,J)){var ee=G-$[0],te=K-$[1],ne=Y-$[0],re=X-$[1],ie=1/a(f((ee*ne+te*re)/(d(ee*ee+te*te)*d(ne*ne+re*re)))/2),ae=d($[0]*$[0]+$[1]*$[1]);z=p(R,(m-ae)/(ie-1)),B=p(R,(h-ae)/(ie+1))}else z=B=0}F>1e-12?B>1e-12?(V=b(Z,Q,G,K,h,B,k),H=b(Y,X,q,J,h,B,k),D.moveTo(V.cx+V.x01,V.cy+V.y01),B<R?D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,h,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),!k),D.arc(H.cx,H.cy,B,n(H.y11,H.x11),n(H.y01,H.x01),!k))):(D.moveTo(G,K),D.arc(0,0,h,A,j,!k)):D.moveTo(G,K),!(m>1e-12)||!(P>1e-12)?D.lineTo(q,J):z>1e-12?(V=b(q,J,Y,X,m,-z,k),H=b(G,K,Z,Q,m,-z,k),D.lineTo(V.cx+V.x01,V.cy+V.y01),z<R?D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,m,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),k),D.arc(H.cx,H.cy,z,n(H.y11,H.x11),n(H.y01,H.x01),!k))):D.arc(0,0,m,N,M,k)}if(D.closePath(),e)return D=null,e+``||null}return k.centroid=function(){var e=(+s.apply(this,arguments)+ +x.apply(this,arguments))/2,t=(+w.apply(this,arguments)+ +T.apply(this,arguments))/2-i/2;return[u(t)*e,a(t)*e]},k.innerRadius=function(t){return arguments.length?(s=typeof t==`function`?t:e(+t),k):s},k.outerRadius=function(t){return arguments.length?(x=typeof t==`function`?t:e(+t),k):x},k.cornerRadius=function(t){return arguments.length?(S=typeof t==`function`?t:e(+t),k):S},k.padRadius=function(t){return arguments.length?(C=t==null?null:typeof t==`function`?t:e(+t),k):C},k.startAngle=function(t){return arguments.length?(w=typeof t==`function`?t:e(+t),k):w},k.endAngle=function(t){return arguments.length?(T=typeof t==`function`?t:e(+t),k):T},k.padAngle=function(t){return arguments.length?(E=typeof t==`function`?t:e(+t),k):E},k.context=function(e){return arguments.length?(D=e??null,k):D},k}export{x as t};
|