@webskill/sdk 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abnfDiagram-O67JEVCF-DtYFjfqO.js +109 -0
- package/dist/agent.d.ts +3 -3
- package/dist/agent.js +1012 -130
- package/dist/{approval-DwN2o2QG.js → approval-DWQlDPbY.js} +102 -16
- package/dist/arc-8U_6NQWm.js +130 -0
- package/dist/architecture-7GRP2DOG-RTw1wpAq.js +4 -0
- package/dist/architectureDiagram-NJMV4G6O-XmmXrJAK.js +7473 -0
- package/dist/array-DQfpQNY8.js +8 -0
- package/dist/blockDiagram-BEXU5L5S-D4yjnCD1.js +2582 -0
- package/dist/browser.d.ts +444 -48
- package/dist/browser.js +1771 -91
- package/dist/c4Diagram-YGBWAQC7-BLmA_JSd.js +3668 -0
- package/dist/channel-CZxxLrG7.js +9 -0
- package/dist/chunk-2Q5K7J3B-Ck03gkFR.js +21 -0
- package/dist/chunk-3FUC2YCW-tr6jmbQf.js +530 -0
- package/dist/chunk-5DYCD2WN-Bt97YGTd.js +58 -0
- package/dist/chunk-5VM5RSS4-BBxa48HL.js +21 -0
- package/dist/chunk-6AEJRKK7-JXK89I-O.js +14 -0
- package/dist/chunk-742MDFTN-CPmgCGwC.js +466 -0
- package/dist/chunk-7INBJB4K-C9jq9o66.js +6552 -0
- package/dist/chunk-7M6MHVWA-BrKCWcR1.js +4894 -0
- package/dist/chunk-7PRAP22T-BHED6GVs.js +95 -0
- package/dist/chunk-DUW6YSOI-DoZj78PO.js +19 -0
- package/dist/chunk-FOHPRMQF-Dkbp819z.js +27189 -0
- package/dist/chunk-GNY47TPC-Bpvq1T49.js +87 -0
- package/dist/chunk-GTNCS2PH-CLmh4I2c.js +686 -0
- package/dist/chunk-GWA4HPMP-B6vN3fkL.js +95 -0
- package/dist/chunk-J5ZVWO5B-Bi_Pcobw.js +26 -0
- package/dist/chunk-JWPE2WC7-D1rC79GS.js +12 -0
- package/dist/chunk-LNGE3PJU-D5OIoe3Z.js +2582 -0
- package/dist/chunk-MBY4JIJT-C34L7a4f.js +2276 -0
- package/dist/chunk-NETBCI7D-Cg84k8N8.js +321 -0
- package/dist/chunk-O7XYJQB3-B6K0KOSL.js +8846 -0
- package/dist/chunk-UA2S7LBM-DxHM29_K.js +612 -0
- package/dist/chunk-WEXAMYUT-Ba6jFWhB.js +33 -0
- package/dist/chunk-XXDRQBXY-DPbSy4kg.js +12 -0
- package/dist/chunk-Y2CYZVJY-U3QOMqrW.js +15 -0
- package/dist/chunk-Z7XXMR3K-oLg1h8F3.js +1038 -0
- package/dist/chunk-ZIGJFQKS-DqEFBuHR.js +2215 -0
- package/dist/classDiagram-v2-NBCMYWYE-BqnOWIUt.js +3845 -0
- package/dist/cose-bilkent-JH36ORCC-C0dTAHVK.js +4270 -0
- package/dist/cynefin-OW5HDTMX-B2QvgEQj.js +4 -0
- package/dist/cynefinDiagram-VND7K2PF-yAWc6Z3W.js +479 -0
- package/dist/cytoscape.esm-C64mRh9B.js +28325 -0
- package/dist/dagre-6A5THRUB-D0w2W27v.js +4816 -0
- package/dist/defaultLocale-B_EoOkSF.js +249 -0
- package/dist/diagram-22UHCM2B-DvgzhUzP.js +6115 -0
- package/dist/diagram-3UASUU5V-DWgUB-ef.js +795 -0
- package/dist/diagram-ATOU4E4O-P1olqwIs.js +553 -0
- package/dist/diagram-CDSNMT55-BUlZuLUe.js +402 -0
- package/dist/diagram-MLGK6HIB-6w5qmkGt.js +186 -0
- package/dist/diagram-MPIPVDR6-DEFiSo8o.js +289 -0
- package/dist/dist-UajCDt3n.js +92 -0
- package/dist/ebnfDiagram-ZINNZB2B-CI8liCfR.js +123 -0
- package/dist/elk-276RUBZZ-3SvW6OAK.js +90034 -0
- package/dist/erDiagram-OPXOYQCR-CPTbKhwP.js +2301 -0
- package/dist/eventmodeling-NTZA5JFV-BlyuqGp0.js +4 -0
- package/dist/flowDiagram-KWPJA3E3-CcUJ6HbV.js +18 -0
- package/dist/ganttDiagram-FUAMR5RP-31UjY0KK.js +3939 -0
- package/dist/{toolSource-C9oNuKmr.js → geometry-wx5ZTYzi.js} +162 -12
- package/dist/gitGraph-4MIJSDKK-ChdVlrk7.js +4 -0
- package/dist/gitGraphDiagram-X574FWY7-DKuxJymB.js +1153 -0
- package/dist/governance.d.ts +3 -3
- package/dist/graphlib-tk9gQYuN.js +4194 -0
- package/dist/{index-B8Tgmpwh.d.ts → index-BiO9_XRk.d.ts} +2 -2
- package/dist/{index-CYLt5u4L.d.ts → index-CjwdZQOS.d.ts} +700 -12
- package/dist/{index-DHopiH_m.d.ts → index-YPd8ZSEa.d.ts} +156 -9
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -6
- package/dist/info-A6RAGUB7-CxRAt9S9.js +4 -0
- package/dist/infoDiagram-VRGFBTTK-pRspGfjZ.js +25 -0
- package/dist/init-CMOIWdg-.js +16 -0
- package/dist/ishikawaDiagram-OU5B5YK6-DKerAPAg.js +975 -0
- package/dist/journeyDiagram-ZHPQQLJL-C4MK-YO5.js +1227 -0
- package/dist/kanban-definition-PNTS6WVX-BqsZpMXx.js +1244 -0
- package/dist/katex-BcRRvyh_.js +26465 -0
- package/dist/{kind-DaKqLX2F.js → kind-Dc8x0HWz.js} +54 -7
- package/dist/line-LgV8iVMV.js +48 -0
- package/dist/linear-BWKR0Tqd.js +393 -0
- package/dist/linkedDocument-CIuh_Yp0.js +416 -0
- package/dist/mcp.d.ts +2 -2
- package/dist/{memoryArtifactStore-D6dLeY55.js → memoryArtifactStore-Bs7glPqm.js} +14 -0
- package/dist/mermaid-parser.core-pYR5siSx.js +754 -0
- package/dist/mermaid.core-DMtwGCHy.js +1756 -0
- package/dist/mindmap-definition-NLK3R4M7-CXbD-myG.js +1312 -0
- package/dist/node.d.ts +3 -3
- package/dist/node.js +2 -2
- package/dist/{openUiLibrary-b0i7F_oZ.js → openUiLibrary-B7j3rLrm.js} +1 -1
- package/dist/{openUiSpecLang-CLXJEeRU.js → openUiSpecLang-BSYYnjay.js} +1 -1
- package/dist/ordinal-CxA6GHQS.js +84 -0
- package/dist/packet-AYTQ26CC-BOm08cxl.js +4 -0
- package/dist/path-C27Z2Bjv.js +106 -0
- package/dist/pegDiagram-GJSIUBJH-BLGJOewQ.js +115 -0
- package/dist/pie-WAS4IAKB-Dvg7glpk.js +4 -0
- package/dist/pieDiagram-5QR66LMP-laoaV_PB.js +298 -0
- package/dist/quadrantDiagram-O4NWA36T-Db_wFBkT.js +2236 -0
- package/dist/radar-RG4KPBEZ-BZDaTu06.js +4 -0
- package/dist/railroad-74A4TZTK-C-UhjkOy.js +4 -0
- package/dist/railroad-abnf-HS5TGJTU-dUKVA4OS.js +4 -0
- package/dist/railroad-ebnf-LZEXJU2U-DzQumk18.js +4 -0
- package/dist/railroad-peg-WCYAUIDC-B3vvTWed.js +4 -0
- package/dist/railroadDiagram-XR7U4H2S-BY0sTM4X.js +89 -0
- package/dist/requirementDiagram-PLB6GJNP-3rkQfEhs.js +2474 -0
- package/dist/rough.cjs-AmDd_NQk.js +1395 -0
- package/dist/sankeyDiagram-IPEJSGJF-CGAJhyG2.js +3578 -0
- package/dist/sequenceDiagram-PO4LG4MO-9FJjFX06.js +5522 -0
- package/dist/sizeCapture-INFHLROL-D8PWxdOn.js +56 -0
- package/dist/{skillVersionStore-B24Jjjry-BkOk9wI_.d.ts → skillVersionStore-B24Jjjry-BY1H7Krp.d.ts} +1 -1
- package/dist/src-NkhI3UMl.js +2653 -0
- package/dist/stateDiagram-v2-GCMORJYK-B0O3wc1-.js +2715 -0
- package/dist/swimlanes-2SLR337P-D4EOnrpu.js +6637 -0
- package/dist/swimlanesDiagram-TC7HE7FX-BUx29EJ9.js +30 -0
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +1 -1
- package/dist/timeline-definition-EJHVYXUP-CrgiiB4C.js +1513 -0
- package/dist/treeView-Q6P3EWNA-C1by-Gzc.js +4 -0
- package/dist/treemap-WGGIJYW6-mC2NZ6ad.js +4 -0
- package/dist/{types-BvTV_05--BW8zDuEk.d.ts → types-CpDRZ0rA-BM5FI9oN.d.ts} +59 -8
- package/dist/ui-react.d.ts +3 -3
- package/dist/ui-react.js +3718 -77
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui.d.ts +3 -3
- package/dist/ui.js +2 -2
- package/dist/usecaseDiagram-POWQR4AR-BUt_TQOY.js +14397 -0
- package/dist/vennDiagram-UO4OBE2U-CwXr0wjA.js +2808 -0
- package/dist/wardley-WFR3VGLG-CVSYjq_S.js +4 -0
- package/dist/wardleyDiagram-VNRHLVJA-Cpfd47dQ.js +874 -0
- package/dist/{webSkillApi-Cib6G-94.js → webSkillApi-Dy-Zjv0y.js} +1 -1
- package/dist/{webskillLitCatalog-W06npwej.js → webskillLitCatalog-D5BCiMCU.js} +1 -1
- package/dist/xychartDiagram-PMCCYNJV-e1TeVoc6.js +2704 -0
- package/package.json +1 -1
- package/dist/linkedDocument-C0gj1sMq.js +0 -245
|
@@ -3,11 +3,11 @@ import { b as parseSkillMarkdown, i as buildCatalog, n as SkillDiscovery, r as S
|
|
|
3
3
|
import { a as atomicWriteText, r as resolveInsideRoot, t as assertSafePathSegment } from "./pathSecurity-B1owvJAF.js";
|
|
4
4
|
import { t as assertRemoteUrlAllowed } from "./urlSafety-CiSuCJvX.js";
|
|
5
5
|
import { c as findUnpairedToolCalls, d as partsToText, f as promptText, l as interruptedToolResult, p as textParts, u as sealToolCallPairs } from "./llm-eIQNO9tr.js";
|
|
6
|
-
import { a as
|
|
6
|
+
import { a as UNSUPPORTED_DOCUMENT_MESSAGE, c as toBase64, f as SPREADSHEET_MIME_TYPE, g as DEFAULT_MAX_DOCUMENT_TEXT_BYTES, h as DEFAULT_MAX_DOCUMENT_BYTES, i as SUPPORTED_DOCUMENT_MIME, l as encodeSpreadsheet, n as READ_LINKED_DOCUMENT_TOOL, o as fromBase64, r as READ_LINKED_DOCUMENT_TOOL_NAME, s as isBytesOnlyDocument, v as TEXT_BUDGETED_CONTENT_TYPES } from "./linkedDocument-CIuh_Yp0.js";
|
|
7
7
|
import { t as mergeCatalogEntries } from "./external-_ZRQe-V9.js";
|
|
8
8
|
import { i as isArtifactCardHidden, n as extractChartSpec, r as admitArtifactMetadata, t as buildRenderResult } from "./renderResult-D9Q-Vu2x.js";
|
|
9
9
|
import { t as extractUiSpecEvents } from "./surface-DVGiCmwq.js";
|
|
10
|
-
import { t as MemoryArtifactStore } from "./memoryArtifactStore-
|
|
10
|
+
import { t as MemoryArtifactStore } from "./memoryArtifactStore-Bs7glPqm.js";
|
|
11
11
|
|
|
12
12
|
//#region ../core/src/render/xmlRenderer.ts
|
|
13
13
|
/** 转义 XML 五个特殊字符:& < > " ' */
|
|
@@ -298,6 +298,44 @@ function resolveSkillDir(skillRoot, dir, relativePath) {
|
|
|
298
298
|
return resolveInsideRoot(skillRoot, `${dir}/${relativePath}`);
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
301
|
+
* 脚本上下文里 `context.writeSpreadsheet` 的图片引用解析(FR-20.8)。
|
|
302
|
+
*
|
|
303
|
+
* 前缀族与文档那一侧同源(分册 11):`artifact:` 读本 run 已写出的产物,
|
|
304
|
+
* `upload:` 读发起本 run 的那条消息里的附件。两条都**不经模型**、也不经沙箱桥——
|
|
305
|
+
* 脚本交上来的始终只是一个引用,字节在这里才第一次出现。
|
|
306
|
+
*
|
|
307
|
+
* `remote:` 不收:表格必须把字节嵌进去,留外链等于交一份在别人机器上打不开的表。
|
|
308
|
+
* 要用远端图,先落成产物再引用。
|
|
309
|
+
*/
|
|
310
|
+
function createScriptImageResolver(deps) {
|
|
311
|
+
return async (ref) => {
|
|
312
|
+
const separator = ref.indexOf(":");
|
|
313
|
+
const kind = separator === -1 ? "" : ref.slice(0, separator);
|
|
314
|
+
const rest = ref.slice(separator + 1);
|
|
315
|
+
if (kind === "artifact") {
|
|
316
|
+
if (deps.artifactStore.readArtifact === void 0) return void 0;
|
|
317
|
+
const found = (await deps.artifactStore.listArtifacts(deps.runId)).find((a) => a.path === rest);
|
|
318
|
+
if (found === void 0) return void 0;
|
|
319
|
+
return {
|
|
320
|
+
bytes: await deps.artifactStore.readArtifact(deps.runId, rest),
|
|
321
|
+
contentType: found.mimeType ?? "application/octet-stream"
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
if (kind === "upload") {
|
|
325
|
+
if (deps.uploadFiles === void 0) return void 0;
|
|
326
|
+
const files = await deps.uploadFiles.list();
|
|
327
|
+
const info = files.find((file) => file.id === rest) ?? files.find((file) => file.name === rest);
|
|
328
|
+
if (info === void 0) return void 0;
|
|
329
|
+
return {
|
|
330
|
+
bytes: await deps.uploadFiles.read(info.id),
|
|
331
|
+
contentType: info.contentType
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
if (kind === "remote") throw new WebSkillError("VALIDATION_FAILED", `image reference "${ref}" cannot be embedded: spreadsheets need the bytes, not a link. Fetch it into an artifact first and reference that.`);
|
|
335
|
+
throw new WebSkillError("VALIDATION_FAILED", `image reference "${ref}" has no known prefix; expected artifact: or upload:`);
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
301
339
|
* 脚本执行上下文:只暴露 readReference / readAsset / readAssetBinary / writeArtifact
|
|
302
340
|
* 四个显式能力,不暴露 fs 本体(沙箱语义,对齐 deferred-items D1)。
|
|
303
341
|
*/
|
|
@@ -335,10 +373,17 @@ function createScriptContext(deps) {
|
|
|
335
373
|
return readFs.readBinary(resolveSkillDir(skillRoot, "assets", relativePath));
|
|
336
374
|
},
|
|
337
375
|
writeArtifact,
|
|
338
|
-
...deps.writeSpreadsheet ? { writeSpreadsheet: async (path, spec, options) =>
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
376
|
+
...deps.writeSpreadsheet ? { writeSpreadsheet: async (path, spec, options) => {
|
|
377
|
+
const resolveImage = createScriptImageResolver({
|
|
378
|
+
artifactStore,
|
|
379
|
+
runId,
|
|
380
|
+
...uploadFiles ? { uploadFiles } : {}
|
|
381
|
+
});
|
|
382
|
+
return writeArtifact(path, await encodeSpreadsheet(spec, resolveImage), {
|
|
383
|
+
mimeType: SPREADSHEET_MIME_TYPE,
|
|
384
|
+
...options?.metadata === void 0 ? {} : { metadata: options.metadata }
|
|
385
|
+
});
|
|
386
|
+
} } : {},
|
|
342
387
|
...confirm ? { confirm } : {},
|
|
343
388
|
...fetchData ? { fetchData } : {},
|
|
344
389
|
...deps.documentSurface ? { documentSurface: true } : {},
|
|
@@ -1292,7 +1337,7 @@ var AgentLoop = class {
|
|
|
1292
1337
|
maxUnknownToolRetries: config.maxUnknownToolRetries ?? 2,
|
|
1293
1338
|
askUserMaxFields: config.askUserMaxFields ?? 20,
|
|
1294
1339
|
maxDocumentBytes: config.maxDocumentBytes ?? 256e5,
|
|
1295
|
-
maxDocumentTextBytes: config.maxDocumentTextBytes ??
|
|
1340
|
+
maxDocumentTextBytes: config.maxDocumentTextBytes ?? 512e4,
|
|
1296
1341
|
visionConcurrency: clampVisionConcurrency(config.visionConcurrency),
|
|
1297
1342
|
temperature: config.temperature,
|
|
1298
1343
|
renderResult: config.renderResult,
|
|
@@ -1351,6 +1396,7 @@ var AgentLoop = class {
|
|
|
1351
1396
|
interactionSeq: 0,
|
|
1352
1397
|
surfaceActionSeq: 0,
|
|
1353
1398
|
documentSeq: 0,
|
|
1399
|
+
binaries: /* @__PURE__ */ new Map(),
|
|
1354
1400
|
messages: [],
|
|
1355
1401
|
turn: 0,
|
|
1356
1402
|
renderBlocks: [],
|
|
@@ -1796,6 +1842,7 @@ var AgentLoop = class {
|
|
|
1796
1842
|
trace,
|
|
1797
1843
|
reader: new SkillReader(this.#deps.fs, this.#deps.skillIndex),
|
|
1798
1844
|
documentSeq: 0,
|
|
1845
|
+
binaries: /* @__PURE__ */ new Map(),
|
|
1799
1846
|
activated: new Set(snapshot.activeSkillNames),
|
|
1800
1847
|
activatedTools: new Map(snapshot.activatedTools.map((d) => [d.name, d])),
|
|
1801
1848
|
skillAllowedTools: new Map(Object.entries(snapshot.skillAllowedTools ?? {})),
|
|
@@ -2226,7 +2273,8 @@ var AgentLoop = class {
|
|
|
2226
2273
|
else if (resolution.kind === "script") result = await this.#handleScriptTool(call, resolution.skillName, resolution.scriptName, state);
|
|
2227
2274
|
else if (source) result = await source.call(call.name, call.arguments, {
|
|
2228
2275
|
runId: state.runId,
|
|
2229
|
-
signal: state.controller.signal
|
|
2276
|
+
signal: state.controller.signal,
|
|
2277
|
+
binaries: { get: (id) => state.binaries.get(id) }
|
|
2230
2278
|
});
|
|
2231
2279
|
else {
|
|
2232
2280
|
if (resolution.kind === "not-found") state.unknownToolCalls += 1;
|
|
@@ -2621,20 +2669,55 @@ var AgentLoop = class {
|
|
|
2621
2669
|
};
|
|
2622
2670
|
}
|
|
2623
2671
|
let text;
|
|
2624
|
-
if (mime
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2672
|
+
if (isBytesOnlyDocument(mime, target.href)) {
|
|
2673
|
+
state.binaries.set(id, {
|
|
2674
|
+
name,
|
|
2675
|
+
mimeType: mime,
|
|
2676
|
+
bytes: fetched.bytes
|
|
2677
|
+
});
|
|
2678
|
+
await audit(record);
|
|
2679
|
+
return {
|
|
2680
|
+
ok: true,
|
|
2681
|
+
content: [{
|
|
2682
|
+
type: "json",
|
|
2683
|
+
data: {
|
|
2684
|
+
id,
|
|
2685
|
+
name,
|
|
2686
|
+
mimeType: mime,
|
|
2687
|
+
bytes: fetched.bytes.length,
|
|
2688
|
+
note: "Stored for tools. Its contents are not readable as text — pass this id to a tool that reads this format."
|
|
2689
|
+
}
|
|
2690
|
+
}]
|
|
2691
|
+
};
|
|
2692
|
+
}
|
|
2693
|
+
const route = {
|
|
2694
|
+
[SUPPORTED_DOCUMENT_MIME.docx]: {
|
|
2695
|
+
kind: "docx",
|
|
2696
|
+
label: "Word documents",
|
|
2697
|
+
...this.#deps.docxExtractor ? { extractor: this.#deps.docxExtractor } : {}
|
|
2698
|
+
},
|
|
2699
|
+
[SUPPORTED_DOCUMENT_MIME.xlsx]: {
|
|
2700
|
+
kind: "xlsx",
|
|
2701
|
+
label: "Excel workbooks",
|
|
2702
|
+
...this.#deps.xlsxExtractor ? { extractor: this.#deps.xlsxExtractor } : {}
|
|
2703
|
+
},
|
|
2704
|
+
[SUPPORTED_DOCUMENT_MIME.pptx]: {
|
|
2705
|
+
kind: "pptx",
|
|
2706
|
+
label: "PowerPoint presentations",
|
|
2707
|
+
...this.#deps.pptxExtractor ? { extractor: this.#deps.pptxExtractor } : {}
|
|
2708
|
+
}
|
|
2709
|
+
}[mime];
|
|
2710
|
+
if (route !== void 0) {
|
|
2711
|
+
if (route.extractor === void 0) {
|
|
2629
2712
|
await audit({
|
|
2630
2713
|
...record,
|
|
2631
2714
|
ok: false,
|
|
2632
|
-
reason: `no ${kind} extractor`
|
|
2715
|
+
reason: `no ${route.kind} extractor`
|
|
2633
2716
|
});
|
|
2634
|
-
return toolError("TOOL_UNSUPPORTED", `${
|
|
2717
|
+
return toolError("TOOL_UNSUPPORTED", `${route.label} cannot be read in this environment: no ${route.kind} text extractor is configured.`);
|
|
2635
2718
|
}
|
|
2636
2719
|
try {
|
|
2637
|
-
text = await extractor(fetched.bytes);
|
|
2720
|
+
text = await route.extractor(fetched.bytes);
|
|
2638
2721
|
} catch (e) {
|
|
2639
2722
|
const message = messageOf(e);
|
|
2640
2723
|
await audit({
|
|
@@ -4380,6 +4463,9 @@ var FsArtifactStore = class {
|
|
|
4380
4463
|
return [];
|
|
4381
4464
|
}
|
|
4382
4465
|
}
|
|
4466
|
+
async readArtifact(runId, path) {
|
|
4467
|
+
return this.#fs.readBinary(this.#artifactPath(runId, path));
|
|
4468
|
+
}
|
|
4383
4469
|
#artifactPath(runId, artifactPath) {
|
|
4384
4470
|
assertSafePathSegment(runId, "runId");
|
|
4385
4471
|
return resolveInsideRoot(`${this.#root}/${runId}`, artifactPath);
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { n as constant_default, t as withPath } from "./path-C27Z2Bjv.js";
|
|
2
|
+
import { a as atan2, c as halfPi, d as pi, f as sin, i as asin, l as max, m as tau, n as abs, o as cos, p as sqrt, r as acos, s as epsilon, u as min } from "./dist-UajCDt3n.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/arc.js
|
|
5
|
+
function arcInnerRadius(d) {
|
|
6
|
+
return d.innerRadius;
|
|
7
|
+
}
|
|
8
|
+
function arcOuterRadius(d) {
|
|
9
|
+
return d.outerRadius;
|
|
10
|
+
}
|
|
11
|
+
function arcStartAngle(d) {
|
|
12
|
+
return d.startAngle;
|
|
13
|
+
}
|
|
14
|
+
function arcEndAngle(d) {
|
|
15
|
+
return d.endAngle;
|
|
16
|
+
}
|
|
17
|
+
function arcPadAngle(d) {
|
|
18
|
+
return d && d.padAngle;
|
|
19
|
+
}
|
|
20
|
+
function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
|
|
21
|
+
var x10 = x1 - x0, y10 = y1 - y0, x32 = x3 - x2, y32 = y3 - y2, t = y32 * x10 - x32 * y10;
|
|
22
|
+
if (t * t < 1e-12) return;
|
|
23
|
+
t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
|
|
24
|
+
return [x0 + t * x10, y0 + t * y10];
|
|
25
|
+
}
|
|
26
|
+
function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
|
|
27
|
+
var x01 = x0 - x1, y01 = y0 - y1, lo = (cw ? rc : -rc) / sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x11 = x0 + ox, y11 = y0 + oy, x10 = x1 + ox, y10 = y1 + oy, x00 = (x11 + x10) / 2, y00 = (y11 + y10) / 2, dx = x10 - x11, dy = y10 - y11, d2 = dx * dx + dy * dy, r = r1 - rc, D = x11 * y10 - x10 * y11, d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D * D)), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x00, dy0 = cy0 - y00, dx1 = cx1 - x00, dy1 = cy1 - y00;
|
|
28
|
+
if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
|
|
29
|
+
return {
|
|
30
|
+
cx: cx0,
|
|
31
|
+
cy: cy0,
|
|
32
|
+
x01: -ox,
|
|
33
|
+
y01: -oy,
|
|
34
|
+
x11: cx0 * (r1 / r - 1),
|
|
35
|
+
y11: cy0 * (r1 / r - 1)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function arc_default() {
|
|
39
|
+
var innerRadius = arcInnerRadius, outerRadius = arcOuterRadius, cornerRadius = constant_default(0), padRadius = null, startAngle = arcStartAngle, endAngle = arcEndAngle, padAngle = arcPadAngle, context = null, path = withPath(arc);
|
|
40
|
+
function arc() {
|
|
41
|
+
var buffer, r, r0 = +innerRadius.apply(this, arguments), r1 = +outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) - halfPi, a1 = endAngle.apply(this, arguments) - halfPi, da = abs(a1 - a0), cw = a1 > a0;
|
|
42
|
+
if (!context) context = buffer = path();
|
|
43
|
+
if (r1 < r0) r = r1, r1 = r0, r0 = r;
|
|
44
|
+
if (!(r1 > 1e-12)) context.moveTo(0, 0);
|
|
45
|
+
else if (da > tau - 1e-12) {
|
|
46
|
+
context.moveTo(r1 * cos(a0), r1 * sin(a0));
|
|
47
|
+
context.arc(0, 0, r1, a0, a1, !cw);
|
|
48
|
+
if (r0 > 1e-12) {
|
|
49
|
+
context.moveTo(r0 * cos(a1), r0 * sin(a1));
|
|
50
|
+
context.arc(0, 0, r0, a1, a0, cw);
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
var a01 = a0, a11 = a1, a00 = a0, a10 = a1, da0 = da, da1 = da, ap = padAngle.apply(this, arguments) / 2, rp = ap > 1e-12 && (padRadius ? +padRadius.apply(this, arguments) : sqrt(r0 * r0 + r1 * r1)), rc = min(abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)), rc0 = rc, rc1 = rc, t0, t1;
|
|
54
|
+
if (rp > 1e-12) {
|
|
55
|
+
var p0 = asin(rp / r0 * sin(ap)), p1 = asin(rp / r1 * sin(ap));
|
|
56
|
+
if ((da0 -= p0 * 2) > 1e-12) p0 *= cw ? 1 : -1, a00 += p0, a10 -= p0;
|
|
57
|
+
else da0 = 0, a00 = a10 = (a0 + a1) / 2;
|
|
58
|
+
if ((da1 -= p1 * 2) > 1e-12) p1 *= cw ? 1 : -1, a01 += p1, a11 -= p1;
|
|
59
|
+
else da1 = 0, a01 = a11 = (a0 + a1) / 2;
|
|
60
|
+
}
|
|
61
|
+
var x01 = r1 * cos(a01), y01 = r1 * sin(a01), x10 = r0 * cos(a10), y10 = r0 * sin(a10);
|
|
62
|
+
if (rc > 1e-12) {
|
|
63
|
+
var x11 = r1 * cos(a11), y11 = r1 * sin(a11), x00 = r0 * cos(a00), y00 = r0 * sin(a00), oc;
|
|
64
|
+
if (da < pi) if (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10)) {
|
|
65
|
+
var ax = x01 - oc[0], ay = y01 - oc[1], bx = x11 - oc[0], by = y11 - oc[1], kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2), lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
|
|
66
|
+
rc0 = min(rc, (r0 - lc) / (kc - 1));
|
|
67
|
+
rc1 = min(rc, (r1 - lc) / (kc + 1));
|
|
68
|
+
} else rc0 = rc1 = 0;
|
|
69
|
+
}
|
|
70
|
+
if (!(da1 > 1e-12)) context.moveTo(x01, y01);
|
|
71
|
+
else if (rc1 > 1e-12) {
|
|
72
|
+
t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
|
|
73
|
+
t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
|
|
74
|
+
context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
75
|
+
if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
76
|
+
else {
|
|
77
|
+
context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
78
|
+
context.arc(0, 0, r1, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
|
|
79
|
+
context.arc(t1.cx, t1.cy, rc1, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
80
|
+
}
|
|
81
|
+
} else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw);
|
|
82
|
+
if (!(r0 > 1e-12) || !(da0 > 1e-12)) context.lineTo(x10, y10);
|
|
83
|
+
else if (rc0 > 1e-12) {
|
|
84
|
+
t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
|
|
85
|
+
t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
|
|
86
|
+
context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
87
|
+
if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
88
|
+
else {
|
|
89
|
+
context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
90
|
+
context.arc(0, 0, r0, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw);
|
|
91
|
+
context.arc(t1.cx, t1.cy, rc0, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
92
|
+
}
|
|
93
|
+
} else context.arc(0, 0, r0, a10, a00, cw);
|
|
94
|
+
}
|
|
95
|
+
context.closePath();
|
|
96
|
+
if (buffer) return context = null, buffer + "" || null;
|
|
97
|
+
}
|
|
98
|
+
arc.centroid = function() {
|
|
99
|
+
var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi / 2;
|
|
100
|
+
return [cos(a) * r, sin(a) * r];
|
|
101
|
+
};
|
|
102
|
+
arc.innerRadius = function(_) {
|
|
103
|
+
return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant_default(+_), arc) : innerRadius;
|
|
104
|
+
};
|
|
105
|
+
arc.outerRadius = function(_) {
|
|
106
|
+
return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant_default(+_), arc) : outerRadius;
|
|
107
|
+
};
|
|
108
|
+
arc.cornerRadius = function(_) {
|
|
109
|
+
return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant_default(+_), arc) : cornerRadius;
|
|
110
|
+
};
|
|
111
|
+
arc.padRadius = function(_) {
|
|
112
|
+
return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant_default(+_), arc) : padRadius;
|
|
113
|
+
};
|
|
114
|
+
arc.startAngle = function(_) {
|
|
115
|
+
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant_default(+_), arc) : startAngle;
|
|
116
|
+
};
|
|
117
|
+
arc.endAngle = function(_) {
|
|
118
|
+
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant_default(+_), arc) : endAngle;
|
|
119
|
+
};
|
|
120
|
+
arc.padAngle = function(_) {
|
|
121
|
+
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant_default(+_), arc) : padAngle;
|
|
122
|
+
};
|
|
123
|
+
arc.context = function(_) {
|
|
124
|
+
return arguments.length ? (context = _ == null ? null : _, arc) : context;
|
|
125
|
+
};
|
|
126
|
+
return arc;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
//#endregion
|
|
130
|
+
export { arc_default as t };
|