@capyclaw/offline-ddr0 0.0.0-stage → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +441 -2
- package/client/client.js +603 -0
- package/cordis.patch.yml +13 -0
- package/docs/STORAGE-MIGRATION.md +136 -0
- package/lib/atomic.mjs +40 -0
- package/lib/http-cache.mjs +42 -0
- package/lib/inbox.mjs +64 -0
- package/lib/media.mjs +242 -0
- package/lib/migrate-json.mjs +101 -0
- package/lib/mirror-index.mjs +105 -0
- package/lib/mirror.mjs +123 -0
- package/lib/proxy.mjs +188 -0
- package/lib/remote.mjs +158 -0
- package/lib/render.mjs +93 -0
- package/lib/repository.mjs +71 -0
- package/lib/store.mjs +610 -0
- package/lib/surface.mjs +74 -0
- package/lib/sync-ui.mjs +108 -0
- package/lib/sync.mjs +433 -0
- package/lib/wire.mjs +211 -0
- package/lib/workstore-repository.mjs +316 -0
- package/lib/workstore.mjs +338 -0
- package/mirror/files/00001.html +2045 -0
- package/mirror/files/00002.json +1 -0
- package/mirror/files/00003.json +1 -0
- package/mirror/files/00004.json +1 -0
- package/mirror/files/00005.json +1 -0
- package/mirror/files/00006.json +1 -0
- package/mirror/files/00007.json +1 -0
- package/mirror/files/00008.json +1 -0
- package/mirror/files/00009.json +1 -0
- package/mirror/files/00010.json +1 -0
- package/mirror/files/00011.json +1 -0
- package/mirror/files/00012.json +1 -0
- package/mirror/files/00013.json +1 -0
- package/mirror/files/00014.json +1 -0
- package/mirror/files/00015.json +1 -0
- package/mirror/files/00016.json +1 -0
- package/mirror/files/00017.json +1 -0
- package/mirror/files/00018.json +1 -0
- package/mirror/files/00019.json +1 -0
- package/mirror/files/00020.json +1 -0
- package/mirror/files/00021.json +1 -0
- package/mirror/files/00022.json +1 -0
- package/mirror/files/00023.js +205 -0
- package/mirror/files/00024.json +1 -0
- package/mirror/files/00025.json +1 -0
- package/mirror/files/00026.json +1 -0
- package/mirror/files/00027.js +51 -0
- package/mirror/files/00028.json +1 -0
- package/mirror/files/00029.json +1 -0
- package/mirror/files/00030.json +1 -0
- package/mirror/files/00031.json +1 -0
- package/mirror/files/00032.json +1 -0
- package/mirror/files/00033.json +1 -0
- package/mirror/files/00034.json +1 -0
- package/mirror/files/00035.json +1 -0
- package/mirror/files/00036.json +1 -0
- package/mirror/files/00037.json +1 -0
- package/mirror/files/00038.json +1 -0
- package/mirror/files/00039.json +1 -0
- package/mirror/files/00040.js +2311 -0
- package/mirror/files/00041.json +1 -0
- package/mirror/files/00042.json +1 -0
- package/mirror/files/00043.json +1 -0
- package/mirror/files/00044.json +1 -0
- package/mirror/files/00045.js +575 -0
- package/mirror/files/00046.json +1 -0
- package/mirror/files/00047.js +575 -0
- package/mirror/files/00048.js +575 -0
- package/mirror/files/00049.json +1 -0
- package/mirror/files/00050.json +1 -0
- package/mirror/files/00051.json +1 -0
- package/mirror/files/00052.json +1 -0
- package/mirror/files/00053.js +575 -0
- package/mirror/files/00054.json +1 -0
- package/mirror/files/00055.json +1 -0
- package/mirror/files/00056.js +575 -0
- package/mirror/files/00057.json +1 -0
- package/mirror/files/00058.json +1 -0
- package/mirror/files/00059.js +360 -0
- package/mirror/files/00060.json +1 -0
- package/mirror/files/00061.json +1 -0
- package/mirror/files/00062.json +1 -0
- package/mirror/files/00063.json +1 -0
- package/mirror/files/00064.json +1 -0
- package/mirror/files/00065.js +144 -0
- package/mirror/files/00066.js +7 -0
- package/mirror/files/00067.json +1 -0
- package/mirror/files/00068.json +1 -0
- package/mirror/files/00069.json +1 -0
- package/mirror/files/00070.json +1 -0
- package/mirror/files/00071.json +1 -0
- package/mirror/files/00072.json +1 -0
- package/mirror/files/00073.js +1 -0
- package/mirror/files/00074.json +1 -0
- package/mirror/files/00075.json +1 -0
- package/mirror/files/00076.json +1 -0
- package/mirror/files/00077.js +45 -0
- package/mirror/files/00078.js +1348 -0
- package/mirror/files/00079.json +1 -0
- package/mirror/files/00080.json +1 -0
- package/mirror/files/00081.js +1 -0
- package/mirror/files/00082.json +1 -0
- package/mirror/files/00083.json +1 -0
- package/mirror/files/00084.js +7 -0
- package/mirror/files/00085.json +1 -0
- package/mirror/files/00086.json +1 -0
- package/mirror/files/00087.js +7 -0
- package/mirror/files/00088.json +1 -0
- package/mirror/files/00089.json +1 -0
- package/mirror/files/00090.js +7 -0
- package/mirror/files/00091.json +1 -0
- package/mirror/files/00092.json +1 -0
- package/mirror/files/00093.js +102 -0
- package/mirror/files/00094.json +1 -0
- package/mirror/files/00095.json +1 -0
- package/mirror/files/00096.json +1 -0
- package/mirror/files/00097.json +1 -0
- package/mirror/files/00098.json +1 -0
- package/mirror/files/00099.json +1 -0
- package/mirror/files/00100.json +1 -0
- package/mirror/files/00101.js +102 -0
- package/mirror/files/00102.json +1 -0
- package/mirror/files/00103.json +1 -0
- package/mirror/files/00104.json +1 -0
- package/mirror/files/00105.json +1 -0
- package/mirror/files/00106.json +1 -0
- package/mirror/files/00107.js +110 -0
- package/mirror/files/00108.json +1 -0
- package/mirror/files/00109.json +1 -0
- package/mirror/files/00110.json +1 -0
- package/mirror/files/00111.json +1 -0
- package/mirror/files/00112.json +1 -0
- package/mirror/files/00113.json +1 -0
- package/mirror/files/00114.json +1 -0
- package/mirror/files/00115.json +1 -0
- package/mirror/files/00116.json +1 -0
- package/mirror/files/00117.json +1 -0
- package/mirror/files/00118.json +1 -0
- package/mirror/files/00119.json +1 -0
- package/mirror/files/00120.json +1 -0
- package/mirror/files/00121.json +1 -0
- package/mirror/files/00122.json +1 -0
- package/mirror/files/00123.json +1 -0
- package/mirror/files/00124.json +1 -0
- package/mirror/files/00125.json +1 -0
- package/mirror/files/00126.json +1 -0
- package/mirror/files/00127.json +1 -0
- package/mirror/files/00128.json +1 -0
- package/mirror/files/00129.json +1 -0
- package/mirror/files/00130.json +1 -0
- package/mirror/files/00131.json +1 -0
- package/mirror/files/00132.js +110 -0
- package/mirror/files/00133.json +1 -0
- package/mirror/files/00134.json +1 -0
- package/mirror/files/00135.json +1 -0
- package/mirror/files/00136.json +1 -0
- package/mirror/files/00137.js +26 -0
- package/mirror/files/00138.json +1 -0
- package/mirror/files/00139.json +1 -0
- package/mirror/files/00140.json +1 -0
- package/mirror/files/00141.json +1 -0
- package/mirror/files/00142.json +1 -0
- package/mirror/files/00143.json +1 -0
- package/mirror/files/00144.js +26 -0
- package/mirror/files/00145.json +1 -0
- package/mirror/files/00146.json +1 -0
- package/mirror/files/00147.js +29 -0
- package/mirror/files/00148.json +1 -0
- package/mirror/files/00149.json +1 -0
- package/mirror/files/00150.js +23 -0
- package/mirror/files/00151.json +1 -0
- package/mirror/files/00152.json +1 -0
- package/mirror/files/00153.js +719 -0
- package/mirror/files/00154.js +9575 -0
- package/mirror/files/00155.js +108 -0
- package/mirror/files/00156.js +379 -0
- package/mirror/files/00157.js +48 -0
- package/mirror/files/00158.json +16 -0
- package/mirror/manifest.json +1582 -0
- package/node_modules/@capyclaw/asset-service/README.md +48 -0
- package/node_modules/@capyclaw/asset-service/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/asset-service/dsh-suite.json +29 -0
- package/node_modules/@capyclaw/asset-service/lib/host.mjs +14 -0
- package/node_modules/@capyclaw/asset-service/package.json +59 -0
- package/node_modules/@capyclaw/asset-service/src/index.mjs +223 -0
- package/node_modules/@capyclaw/foundation/README.md +51 -0
- package/node_modules/@capyclaw/foundation/abi/bridge.mjs +86 -0
- package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
- package/node_modules/@capyclaw/foundation/abi/index.mjs +35 -0
- package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
- package/node_modules/@capyclaw/foundation/abi/loader.mjs +345 -0
- package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
- package/node_modules/@capyclaw/foundation/abi/spec.mjs +255 -0
- package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
- package/node_modules/@capyclaw/foundation/abi/version.mjs +82 -0
- package/node_modules/@capyclaw/foundation/cordis.patch.yml +5 -0
- package/node_modules/@capyclaw/foundation/kit/index.mjs +6 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +98 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +35 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +69 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +55 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +68 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +113 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +77 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +56 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +50 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +64 -0
- package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +42 -0
- package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +34 -0
- package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +85 -0
- package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +50 -0
- package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +160 -0
- package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
- package/node_modules/@capyclaw/foundation/lib/kernel.mjs +185 -0
- package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +87 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +60 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +51 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +188 -0
- package/node_modules/@capyclaw/foundation/package.json +53 -0
- package/node_modules/@capyclaw/foundation/runtime/index.mjs +20 -0
- package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +100 -0
- package/node_modules/@capyclaw/plugin-kit/README.md +70 -0
- package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +103 -0
- package/node_modules/@capyclaw/plugin-kit/package.json +69 -0
- package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +56 -0
- package/node_modules/@capyclaw/plugin-kit/src/config.mjs +142 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +129 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +139 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +219 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +13 -0
- package/node_modules/@capyclaw/plugin-kit/src/index.mjs +13 -0
- package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +230 -0
- package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +128 -0
- package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +307 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +45 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +113 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +150 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
- package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +82 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +109 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +17 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +89 -0
- package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +57 -0
- package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +150 -0
- package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +82 -0
- package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +132 -0
- package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +130 -0
- package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +656 -0
- package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
- package/node_modules/@capyclaw/service-host/README.md +86 -0
- package/node_modules/@capyclaw/service-host/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/service-host/dsh-suite.json +29 -0
- package/node_modules/@capyclaw/service-host/lib/host.mjs +22 -0
- package/node_modules/@capyclaw/service-host/package.json +60 -0
- package/node_modules/@capyclaw/service-host/src/index.mjs +571 -0
- package/node_modules/@capyclaw/service-host/src/tuning.mjs +63 -0
- package/node_modules/@capyclaw/suite-kit/README.md +238 -0
- package/node_modules/@capyclaw/suite-kit/bin/dsh-domain.mjs +98 -0
- package/node_modules/@capyclaw/suite-kit/bin/dsh-suite.mjs +174 -0
- package/node_modules/@capyclaw/suite-kit/client/embed.js +35 -0
- package/node_modules/@capyclaw/suite-kit/domain.schema.json +129 -0
- package/node_modules/@capyclaw/suite-kit/package.json +54 -0
- package/node_modules/@capyclaw/suite-kit/src/activation-registry.mjs +184 -0
- package/node_modules/@capyclaw/suite-kit/src/artifacts.mjs +131 -0
- package/node_modules/@capyclaw/suite-kit/src/capability.mjs +181 -0
- package/node_modules/@capyclaw/suite-kit/src/compose.mjs +201 -0
- package/node_modules/@capyclaw/suite-kit/src/domain.mjs +138 -0
- package/node_modules/@capyclaw/suite-kit/src/embed.mjs +81 -0
- package/node_modules/@capyclaw/suite-kit/src/index.mjs +10 -0
- package/node_modules/@capyclaw/suite-kit/src/manifest.mjs +263 -0
- package/node_modules/@capyclaw/suite-kit/src/orchestration.mjs +100 -0
- package/node_modules/@capyclaw/suite-kit/src/profile.mjs +584 -0
- package/node_modules/@capyclaw/suite-kit/src/surface.mjs +28 -0
- package/node_modules/@capyclaw/suite-kit/suite.schema.json +112 -0
- package/node_modules/@capyclaw/work-store/README.md +83 -0
- package/node_modules/@capyclaw/work-store/STANDARD.md +257 -0
- package/node_modules/@capyclaw/work-store/cordis.patch.yml +3 -0
- package/node_modules/@capyclaw/work-store/dsh-suite.json +26 -0
- package/node_modules/@capyclaw/work-store/icon.svg +7 -0
- package/node_modules/@capyclaw/work-store/lib/host.mjs +21 -0
- package/node_modules/@capyclaw/work-store/package.json +68 -0
- package/node_modules/@capyclaw/work-store/src/backend.mjs +89 -0
- package/node_modules/@capyclaw/work-store/src/db.mjs +199 -0
- package/node_modules/@capyclaw/work-store/src/envelope.mjs +132 -0
- package/node_modules/@capyclaw/work-store/src/index.mjs +570 -0
- package/node_modules/@capyclaw/work-store/src/interop.mjs +70 -0
- package/node_modules/@capyclaw/work-store/src/refs.mjs +99 -0
- package/node_modules/@capyclaw/work-store/src/routes.mjs +135 -0
- package/package.json +82 -4
- package/plugin.mjs +636 -0
- package/static/index.html +2068 -0
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @caps flow-kit
|
|
3
|
+
* 图谱装饰器套件 —— 只读查看版(V12,复刻 WORKS-2521 Flow 编排台的画布视图)。
|
|
4
|
+
* 宿主作品 META view.decorator 钉版引用本套件后,WorkView 舞台经
|
|
5
|
+
* /version/<n>/decorator.js 端点下发本套件字节,把作品的 view.source 数据
|
|
6
|
+
* (裸 JSON 直供 ctx.viewDoc,围栏物化保底)渲染成只读编排画布。
|
|
7
|
+
*
|
|
8
|
+
* V12(2026-09-28,用户裁定「参考 2522 背后那台程序复刻查看功能」):
|
|
9
|
+
* 视觉与走线复刻 2521 编辑器——同款点阵画布 / 半透明节点卡 / 空进实出
|
|
10
|
+
* 端口 / bezier 走线(同侧外弓·异侧顺流·回流 U 绕 + 扇出分层 + 叠边排斥)
|
|
11
|
+
* / when 守卫虚线 / 边界出入门。零编辑面:无工具栏、无拖节点、无拉线、
|
|
12
|
+
* 无右键菜单;查看交互 = 平移 / 滚轮缩放 / 双击适配 / 点选高亮 /
|
|
13
|
+
* 双击节点开只读参数卡。
|
|
14
|
+
* 主题跟随:桥 fw:theme 推送 + theme-query 补拉(亮暗 token 同 2521)。
|
|
15
|
+
* 守卫形注册:主文档无 Work 全局,typeof 判定后再注册。
|
|
16
|
+
* 舞台契约:不改写宿主 stage 定位(absolute/inset:0 撑高),只追加子层。
|
|
17
|
+
*/
|
|
18
|
+
(function () {
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/* ---------- 主题令牌(同 2521 tokens.css 子集;亮值默认、暗值翻转) ---------- */
|
|
22
|
+
var CSS_TEXT = [
|
|
23
|
+
':root{--primary:#5C4033;--primary-2:#3E2A20;--text-1:#5C4033;',
|
|
24
|
+
' --text-2:#7A5C47;--text-3:#9C7E68;--text-muted:#B5987F;',
|
|
25
|
+
' --border:#DCE3EC;--border-soft:#E4EAF1;--neu-bg:#E0E5EC;',
|
|
26
|
+
' --neu-inset:#D1D9E6;--neu-radius-sub:16px;}',
|
|
27
|
+
':root[data-theme="dark"]{color-scheme:dark;--primary:#C89E6E;',
|
|
28
|
+
' --primary-2:#E2C29B;--text-1:#F2F2F2;--text-2:#C9C9C9;',
|
|
29
|
+
' --text-3:#999999;--text-muted:#6E6E6E;--border:#3A3A3A;',
|
|
30
|
+
' --border-soft:#303030;--neu-bg:#1A1A1A;--neu-inset:#131313;}',
|
|
31
|
+
'*{box-sizing:border-box;}',
|
|
32
|
+
'.flowed-canvas{position:absolute;inset:0;overflow:hidden;',
|
|
33
|
+
' touch-action:none;background:var(--neu-bg);',
|
|
34
|
+
' font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",',
|
|
35
|
+
' "PingFang SC","Microsoft YaHei",sans-serif;color:var(--text-1);}',
|
|
36
|
+
'.flowed-canvas::before{content:"";position:absolute;inset:0;',
|
|
37
|
+
' background-image:radial-gradient(circle,var(--text-3) 1px,',
|
|
38
|
+
' transparent 1.4px);background-size:22px 22px;opacity:.26;',
|
|
39
|
+
' pointer-events:none;z-index:0;}',
|
|
40
|
+
'.flowed-world{position:absolute;left:0;top:0;transform-origin:0 0;z-index:1;}',
|
|
41
|
+
'.flowed-edges{position:absolute;left:0;top:0;overflow:visible;}',
|
|
42
|
+
'.flowed-edge-hit{fill:none;stroke:transparent;stroke-width:14;}',
|
|
43
|
+
'.flowed-edge-line{fill:none;stroke:var(--text-2);stroke-width:2;opacity:.9;}',
|
|
44
|
+
'.flowed-edge.selected .flowed-edge-line{stroke:#f6ad55;stroke-width:3;}',
|
|
45
|
+
'.flowed-edge-guard .flowed-edge-line{stroke-dasharray:7 5;}',
|
|
46
|
+
'.flowed-edge-whenlabel{fill:#b794f4;font-size:11px;font-weight:600;}',
|
|
47
|
+
'.flowed-node{position:absolute;width:180px;height:40px;',
|
|
48
|
+
' background:color-mix(in srgb,var(--neu-bg) 55%,transparent);',
|
|
49
|
+
' background:rgba(224,229,236,.55);',
|
|
50
|
+
' border:1px solid var(--border-soft);border-radius:var(--neu-radius-sub);',
|
|
51
|
+
' box-shadow:3px 3px 7px rgba(163,177,198,.45);cursor:default;}',
|
|
52
|
+
':root[data-theme="dark"] .flowed-node{background:rgba(26,26,26,.62);',
|
|
53
|
+
' box-shadow:3px 3px 7px rgba(0,0,0,.5);}',
|
|
54
|
+
'.flowed-node.selected{border-color:#f6ad55;',
|
|
55
|
+
' box-shadow:0 0 0 2px rgba(246,173,85,.35);}',
|
|
56
|
+
'.flowed-node-head{display:flex;align-items:center;gap:6px;padding:6px 8px;',
|
|
57
|
+
' height:100%;font-size:12px;border-radius:inherit;}',
|
|
58
|
+
'.flowed-node-type{font-size:10px;padding:1px 6px;border-radius:4px;',
|
|
59
|
+
' background:#2b6cb0;color:#fff;flex-shrink:0;}',
|
|
60
|
+
'.flowed-node-type.t-pyfunc{background:#2f855a;}',
|
|
61
|
+
'.flowed-node-id{flex:1;overflow:hidden;text-overflow:ellipsis;',
|
|
62
|
+
' white-space:nowrap;font-weight:600;}',
|
|
63
|
+
'.flowed-port{position:absolute;top:50%;margin-top:-8px;width:16px;',
|
|
64
|
+
' height:16px;border-radius:50%;border:2px solid var(--text-3);}',
|
|
65
|
+
'.flowed-port.in{left:-7px;background:transparent;',
|
|
66
|
+
' border-color:var(--primary);}',
|
|
67
|
+
'.flowed-port.out{right:-7px;background:var(--primary);}',
|
|
68
|
+
'.flowed-bport{position:absolute;top:50%;width:16px;height:16px;',
|
|
69
|
+
' margin-top:-8px;z-index:6;}',
|
|
70
|
+
'.flowed-bport.in{left:9px;}',
|
|
71
|
+
'.flowed-bport.out{right:9px;}',
|
|
72
|
+
'.flowed-bport::before{content:"";position:absolute;inset:0;',
|
|
73
|
+
' border-radius:50%;background:var(--neu-bg);border:2px solid var(--text-3);}',
|
|
74
|
+
'.flowed-bport.in::before{background:transparent;',
|
|
75
|
+
' border-color:var(--primary);}',
|
|
76
|
+
'.flowed-bport.out::before{background:var(--primary);}',
|
|
77
|
+
'.flowed-hint{position:absolute;left:12px;top:10px;z-index:8;',
|
|
78
|
+
' font-size:12px;opacity:.6;pointer-events:none;}',
|
|
79
|
+
'.flowed-card{position:absolute;right:12px;top:12px;z-index:9;',
|
|
80
|
+
' width:min(340px,72%);max-height:calc(100% - 24px);overflow:auto;',
|
|
81
|
+
' background:color-mix(in srgb,var(--neu-bg) 92%,transparent);',
|
|
82
|
+
' border:1px solid var(--border-soft);border-radius:var(--neu-radius-sub);',
|
|
83
|
+
' box-shadow:5px 5px 10px rgba(163,177,198,.5);padding:12px 14px;',
|
|
84
|
+
' font-size:12px;line-height:1.55;}',
|
|
85
|
+
':root[data-theme="dark"] .flowed-card{background:rgba(26,26,26,.94);',
|
|
86
|
+
' box-shadow:5px 5px 10px rgba(0,0,0,.55);}',
|
|
87
|
+
'.flowed-card h4{margin:0 0 6px;font-size:13px;display:flex;',
|
|
88
|
+
' align-items:center;gap:6px;}',
|
|
89
|
+
'.flowed-card-close{margin-left:auto;border:none;background:transparent;',
|
|
90
|
+
' color:inherit;font-size:16px;cursor:pointer;line-height:1;padding:2px 6px;}',
|
|
91
|
+
'.flowed-card pre{margin:4px 0 8px;padding:8px;white-space:pre-wrap;',
|
|
92
|
+
' word-break:break-all;background:var(--neu-inset);border-radius:8px;',
|
|
93
|
+
' font-size:11px;max-height:180px;overflow:auto;color:var(--text-1);',
|
|
94
|
+
' -webkit-user-select:text;user-select:text;}',
|
|
95
|
+
'.flowed-card .k{color:var(--text-3);margin-right:4px;}',
|
|
96
|
+
'.flowed-empty{position:absolute;inset:0;display:flex;align-items:center;',
|
|
97
|
+
' justify-content:center;font-size:13px;opacity:.6;padding:20px;',
|
|
98
|
+
' text-align:center;}',
|
|
99
|
+
].join('\n');
|
|
100
|
+
|
|
101
|
+
var NODE_W = 180, NODE_H = 40, PORT_CY = NODE_H / 2;
|
|
102
|
+
var CANVAS_IN = '__canvas_in', CANVAS_OUT = '__canvas_out';
|
|
103
|
+
var TYPE_LABELS = { pyfunc: '函数' };
|
|
104
|
+
|
|
105
|
+
function parseDoc(md) {
|
|
106
|
+
md = String(md || '').trim();
|
|
107
|
+
if (!md) return null;
|
|
108
|
+
var m = /```(?:workflow|workflow-source)[ \t]*\r?\n([\s\S]*?)```/
|
|
109
|
+
.exec(md);
|
|
110
|
+
var body = m ? m[1] : (/^[\{\[]/.test(md) ? md : '');
|
|
111
|
+
if (!body) return null;
|
|
112
|
+
try {
|
|
113
|
+
var g = JSON.parse(body);
|
|
114
|
+
} catch (e) { return null; }
|
|
115
|
+
if (!g || !Array.isArray(g.nodes) || !g.nodes.length) return null;
|
|
116
|
+
return g;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* 缺坐标网格补排(有坐标尊重坐标) */
|
|
120
|
+
function layout(g) {
|
|
121
|
+
var nodes = g.nodes.slice();
|
|
122
|
+
var cols = Math.max(1, Math.ceil(Math.sqrt(nodes.length)));
|
|
123
|
+
nodes.forEach(function (n, i) {
|
|
124
|
+
if (typeof n.x !== 'number') n.x = (i % cols) * 260 + 60;
|
|
125
|
+
if (typeof n.y !== 'number') n.y = Math.floor(i / cols) * 120 + 60;
|
|
126
|
+
});
|
|
127
|
+
return g;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* ---------- 走线(复刻 2521 flow-alg-edges:纯函数) ---------- */
|
|
131
|
+
function branchOf(a, b, fa, fb) {
|
|
132
|
+
if (fa === fb) return 'bow';
|
|
133
|
+
return (b.x >= a.x) === (fa > 0) ? 'flow' : 'back';
|
|
134
|
+
}
|
|
135
|
+
function shiftC(c, a, b) {
|
|
136
|
+
var k = a.spread == null ? (b.spread || 0) : a.spread;
|
|
137
|
+
if (!k) return c;
|
|
138
|
+
var vx = b.x - a.x, vy = b.y - a.y;
|
|
139
|
+
var vl = Math.sqrt(vx * vx + vy * vy);
|
|
140
|
+
var nx = vl > 0.001 ? -vy / vl : 0;
|
|
141
|
+
var ny = vl > 0.001 ? vx / vl : 1;
|
|
142
|
+
return { c1x: c.c1x + nx * k, c1y: c.c1y + ny * k,
|
|
143
|
+
c2x: c.c2x + nx * k, c2y: c.c2y + ny * k };
|
|
144
|
+
}
|
|
145
|
+
function controls(a, b) {
|
|
146
|
+
var fa = a.face == null ? 1 : a.face;
|
|
147
|
+
var fb = b.face == null ? -1 : b.face;
|
|
148
|
+
if (fa === fb) {
|
|
149
|
+
var span = Math.max(Math.abs(b.x - a.x), Math.abs(b.y - a.y));
|
|
150
|
+
var mul = a.bowMul == null ? 1 : a.bowMul;
|
|
151
|
+
var bow = Math.max(60, Math.min(190, span * 0.62)) * mul;
|
|
152
|
+
bow = Math.min(bow, 240);
|
|
153
|
+
return { c1x: a.x + fa * bow, c1y: a.y,
|
|
154
|
+
c2x: b.x + fb * bow, c2y: b.y };
|
|
155
|
+
}
|
|
156
|
+
var dx = Math.max(50, Math.abs(b.x - a.x) / 2);
|
|
157
|
+
if (branchOf(a, b, fa, fb) === 'flow') {
|
|
158
|
+
return shiftC({ c1x: a.x + fa * dx, c1y: a.y,
|
|
159
|
+
c2x: b.x + fb * dx, c2y: b.y }, a, b);
|
|
160
|
+
}
|
|
161
|
+
var dy = Math.min(160, Math.max(60, dx / 2));
|
|
162
|
+
var dir = b.y >= a.y ? 1 : -1;
|
|
163
|
+
return shiftC({ c1x: a.x, c1y: a.y + dy * dir,
|
|
164
|
+
c2x: b.x, c2y: b.y + dy * dir }, a, b);
|
|
165
|
+
}
|
|
166
|
+
function pathC(a, c, b) {
|
|
167
|
+
return 'M ' + a.x + ' ' + a.y + ' C ' + c.c1x + ' ' + c.c1y
|
|
168
|
+
+ ', ' + c.c2x + ' ' + c.c2y + ', ' + b.x + ' ' + b.y;
|
|
169
|
+
}
|
|
170
|
+
function geom(pa, pb) {
|
|
171
|
+
var c = controls(pa, pb);
|
|
172
|
+
return { d: pathC(pa, c, pb),
|
|
173
|
+
pa: pa, pb: pb, c: c };
|
|
174
|
+
}
|
|
175
|
+
function lineD(g) {
|
|
176
|
+
var ex = g.pb.x - g.c.c2x, ey = g.pb.y - g.c.c2y;
|
|
177
|
+
var tl = Math.sqrt(ex * ex + ey * ey);
|
|
178
|
+
if (tl < 0.001) { ex = 1; ey = 0; } else { ex /= tl; ey /= tl; }
|
|
179
|
+
return pathC(g.pa, g.c, { x: g.pb.x - ex * 9, y: g.pb.y - ey * 9 });
|
|
180
|
+
}
|
|
181
|
+
/* 同源同面扇出分层 */
|
|
182
|
+
function computeLanes(conns, anchorOf, keyOf) {
|
|
183
|
+
var groups = {};
|
|
184
|
+
(conns || []).forEach(function (c) {
|
|
185
|
+
var a = anchorOf(c.from, true);
|
|
186
|
+
if (!a) return;
|
|
187
|
+
var f = a.face == null ? 1 : (a.face > 0 ? 1 : 0);
|
|
188
|
+
var key = c.from + '\u0000' + f;
|
|
189
|
+
(groups[key] = groups[key] || []).push({ c: c, a: a });
|
|
190
|
+
});
|
|
191
|
+
var lane = {};
|
|
192
|
+
Object.keys(groups).forEach(function (k) {
|
|
193
|
+
var list = groups[k];
|
|
194
|
+
if (list.length < 2) return;
|
|
195
|
+
var f = k.indexOf('\u00001') >= 0 ? 1 : -1;
|
|
196
|
+
list.forEach(function (it) {
|
|
197
|
+
var t = anchorOf(it.c.to, false);
|
|
198
|
+
if (t) it.ang = Math.atan2(t.y - it.a.y, (t.x - it.a.x) * f);
|
|
199
|
+
});
|
|
200
|
+
list.sort(function (x, y) { return x.ang - y.ang; });
|
|
201
|
+
list.forEach(function (it, i) {
|
|
202
|
+
lane[keyOf(it.c)] = 1 + 0.55 * (list.length - 1 - i);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
return lane;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* ---------- 只读画布 ---------- */
|
|
209
|
+
var svgNS = 'http://www.w3.org/2000/svg';
|
|
210
|
+
|
|
211
|
+
function mount(ctx) {
|
|
212
|
+
var stage = ctx.stage;
|
|
213
|
+
var doc = document;
|
|
214
|
+
var style = doc.createElement('style');
|
|
215
|
+
style.textContent = CSS_TEXT;
|
|
216
|
+
doc.head.appendChild(style);
|
|
217
|
+
|
|
218
|
+
/* 主题跟随(同 2521:fw:theme 推送 + theme-query 补拉) */
|
|
219
|
+
function onThemeMode(mode) {
|
|
220
|
+
doc.documentElement.setAttribute('data-theme',
|
|
221
|
+
mode === 'dark' ? 'dark' : 'light');
|
|
222
|
+
}
|
|
223
|
+
window.addEventListener('message', function (e) {
|
|
224
|
+
var d = e.data;
|
|
225
|
+
if (d && d.type === 'fw:theme') onThemeMode(d.mode);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
var g = parseDoc(ctx.viewDoc || ctx.doc);
|
|
229
|
+
var title = (ctx.work && ctx.work.ref) || '';
|
|
230
|
+
if (!g) {
|
|
231
|
+
var emp = doc.createElement('div');
|
|
232
|
+
emp.className = 'flowed-empty';
|
|
233
|
+
emp.textContent = (title ? title + ' · ' : '')
|
|
234
|
+
+ '无工作流数据(view.source 分节为空)';
|
|
235
|
+
stage.appendChild(emp);
|
|
236
|
+
if (typeof ctx.ready === 'function') ctx.ready();
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
layout(g);
|
|
240
|
+
onThemeMode(window.__fw_theme_guess || 'light');
|
|
241
|
+
try { parent.postMessage({ type: 'theme-query' }, '*'); }
|
|
242
|
+
catch (e) { /* 父已离场 */ }
|
|
243
|
+
|
|
244
|
+
var canvas = doc.createElement('div');
|
|
245
|
+
canvas.className = 'flowed-canvas';
|
|
246
|
+
stage.appendChild(canvas);
|
|
247
|
+
var hint = doc.createElement('div');
|
|
248
|
+
hint.className = 'flowed-hint';
|
|
249
|
+
hint.textContent = (g.name || title ? (g.name || title) + ' · ' : '')
|
|
250
|
+
+ '只读 · 拖动平移 · 滚轮缩放 · 双击适配 · 双击节点看参数';
|
|
251
|
+
canvas.appendChild(hint);
|
|
252
|
+
|
|
253
|
+
var world = doc.createElement('div');
|
|
254
|
+
world.className = 'flowed-world';
|
|
255
|
+
canvas.appendChild(world);
|
|
256
|
+
var svg = doc.createElementNS(svgNS, 'svg');
|
|
257
|
+
svg.setAttribute('class', 'flowed-edges');
|
|
258
|
+
world.appendChild(svg);
|
|
259
|
+
|
|
260
|
+
/* 箭头 marker(同 2521:userSpaceOnUse,不随线宽变) */
|
|
261
|
+
var defs = doc.createElementNS(svgNS, 'defs');
|
|
262
|
+
['flowed-arrow', 'flowed-arrow-sel'].forEach(function (id, i) {
|
|
263
|
+
var mk = doc.createElementNS(svgNS, 'marker');
|
|
264
|
+
mk.setAttribute('id', id);
|
|
265
|
+
mk.setAttribute('viewBox', '0 0 10 10');
|
|
266
|
+
mk.setAttribute('refX', '10');
|
|
267
|
+
mk.setAttribute('refY', '5');
|
|
268
|
+
mk.setAttribute('markerWidth', '11');
|
|
269
|
+
mk.setAttribute('markerHeight', '11');
|
|
270
|
+
mk.setAttribute('markerUnits', 'userSpaceOnUse');
|
|
271
|
+
mk.setAttribute('orient', 'auto');
|
|
272
|
+
mk.setAttribute('style', 'fill:' + (i ? '#f6ad55' : 'var(--text-2)')
|
|
273
|
+
+ ';fill-opacity:1');
|
|
274
|
+
var tri = doc.createElementNS(svgNS, 'path');
|
|
275
|
+
tri.setAttribute('d', 'M0,0 L10,5 L0,10 Z');
|
|
276
|
+
mk.appendChild(tri);
|
|
277
|
+
defs.appendChild(mk);
|
|
278
|
+
});
|
|
279
|
+
svg.appendChild(defs);
|
|
280
|
+
|
|
281
|
+
var byId = {};
|
|
282
|
+
g.nodes.forEach(function (n) { byId[n.id] = n; });
|
|
283
|
+
|
|
284
|
+
var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
285
|
+
g.nodes.forEach(function (n) {
|
|
286
|
+
minX = Math.min(minX, n.x); minY = Math.min(minY, n.y);
|
|
287
|
+
maxX = Math.max(maxX, n.x + NODE_W);
|
|
288
|
+
maxY = Math.max(maxY, n.y + NODE_H);
|
|
289
|
+
});
|
|
290
|
+
var W = Math.max(maxX + 300, 2000), H = Math.max(maxY + 300, 1600);
|
|
291
|
+
svg.setAttribute('width', W);
|
|
292
|
+
svg.setAttribute('height', H);
|
|
293
|
+
svg.style.width = W + 'px';
|
|
294
|
+
svg.style.height = H + 'px';
|
|
295
|
+
|
|
296
|
+
/* 边界出入门(屏幕钉位;__canvas_in/out 边锚在其圆心) */
|
|
297
|
+
var inDot = doc.createElement('div');
|
|
298
|
+
inDot.className = 'flowed-bport in';
|
|
299
|
+
var outDot = doc.createElement('div');
|
|
300
|
+
outDot.className = 'flowed-bport out';
|
|
301
|
+
canvas.appendChild(inDot);
|
|
302
|
+
canvas.appendChild(outDot);
|
|
303
|
+
|
|
304
|
+
/* 视图态(平移/缩放;世界坐标静态、边界边随镜头重算) */
|
|
305
|
+
var panX = 0, panY = 0, zoom = 1;
|
|
306
|
+
function applyTransform() {
|
|
307
|
+
world.style.transform = 'translate(' + panX + 'px,' + panY
|
|
308
|
+
+ 'px) scale(' + zoom + ')';
|
|
309
|
+
syncBound();
|
|
310
|
+
}
|
|
311
|
+
function toWorld(cx, cy) {
|
|
312
|
+
var r = canvas.getBoundingClientRect();
|
|
313
|
+
return { x: (cx - r.left - panX) / zoom,
|
|
314
|
+
y: (cy - r.top - panY) / zoom };
|
|
315
|
+
}
|
|
316
|
+
function boundWorldPos(side) {
|
|
317
|
+
var d = side === 'in' ? inDot : outDot;
|
|
318
|
+
var r = d.getBoundingClientRect(), cr = canvas.getBoundingClientRect();
|
|
319
|
+
return { x: (r.left + r.width / 2 - cr.left - panX) / zoom,
|
|
320
|
+
y: (r.top + r.height / 2 - cr.top - panY) / zoom };
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function anchorPt(id, isFrom) {
|
|
324
|
+
if (id === CANVAS_IN) { var p = boundWorldPos('in'); p.face = 1; return p; }
|
|
325
|
+
if (id === CANVAS_OUT) { var q = boundWorldPos('out'); q.face = -1; return q; }
|
|
326
|
+
var n = byId[id];
|
|
327
|
+
if (!n) return null;
|
|
328
|
+
var out = isFrom;
|
|
329
|
+
return { x: n.x + (out ? NODE_W : 2), y: n.y + PORT_CY,
|
|
330
|
+
face: out ? 1 : -1 };
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
var nodeEls = {};
|
|
334
|
+
g.nodes.forEach(function (n) {
|
|
335
|
+
var div = doc.createElement('div');
|
|
336
|
+
div.className = 'flowed-node';
|
|
337
|
+
div.style.left = n.x + 'px';
|
|
338
|
+
div.style.top = n.y + 'px';
|
|
339
|
+
div.setAttribute('data-id', n.id);
|
|
340
|
+
var head = doc.createElement('div');
|
|
341
|
+
head.className = 'flowed-node-head';
|
|
342
|
+
var badge = doc.createElement('span');
|
|
343
|
+
badge.className = 'flowed-node-type t-' + n.type;
|
|
344
|
+
badge.textContent = n.tag || TYPE_LABELS[n.type] || n.type;
|
|
345
|
+
if (n.color) badge.style.background = n.color;
|
|
346
|
+
head.appendChild(badge);
|
|
347
|
+
var idEl = doc.createElement('span');
|
|
348
|
+
idEl.className = 'flowed-node-id';
|
|
349
|
+
idEl.textContent = n.id;
|
|
350
|
+
head.appendChild(idEl);
|
|
351
|
+
div.appendChild(head);
|
|
352
|
+
var pin = doc.createElement('span');
|
|
353
|
+
pin.className = 'flowed-port in';
|
|
354
|
+
var pout = doc.createElement('span');
|
|
355
|
+
pout.className = 'flowed-port out';
|
|
356
|
+
div.appendChild(pin);
|
|
357
|
+
div.appendChild(pout);
|
|
358
|
+
world.appendChild(div);
|
|
359
|
+
nodeEls[n.id] = div;
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
var conns = (Array.isArray(g.edges) ? g.edges : []).filter(function (e) {
|
|
363
|
+
var known = function (x) { return byId[x] || x === CANVAS_IN
|
|
364
|
+
|| x === CANVAS_OUT; };
|
|
365
|
+
return known(e.from) && known(e.to);
|
|
366
|
+
}).map(function (e) {
|
|
367
|
+
return { from: e.from, to: e.to, when: e.when || '' };
|
|
368
|
+
});
|
|
369
|
+
function keyOf(c) { return c.from + '|' + c.to; }
|
|
370
|
+
|
|
371
|
+
var lane = computeLanes(conns, anchorPt, keyOf);
|
|
372
|
+
var wlpSeq = 0;
|
|
373
|
+
var boundEdgeEls = [];
|
|
374
|
+
conns.forEach(function (c) {
|
|
375
|
+
var aA = anchorPt(c.from, true);
|
|
376
|
+
var aB = anchorPt(c.to, false);
|
|
377
|
+
if (!aA || !aB) return;
|
|
378
|
+
var lm = lane[keyOf(c)];
|
|
379
|
+
if (lm != null) aA.bowMul = lm;
|
|
380
|
+
var gm = geom(aA, aB);
|
|
381
|
+
var ge = doc.createElementNS(svgNS, 'g');
|
|
382
|
+
var guard = !!(c.when && String(c.when).trim());
|
|
383
|
+
ge.setAttribute('class', 'flowed-edge'
|
|
384
|
+
+ (guard ? ' flowed-edge-guard' : ''));
|
|
385
|
+
var hit = doc.createElementNS(svgNS, 'path');
|
|
386
|
+
hit.setAttribute('class', 'flowed-edge-hit');
|
|
387
|
+
hit.setAttribute('d', gm.d);
|
|
388
|
+
var line = doc.createElementNS(svgNS, 'path');
|
|
389
|
+
line.setAttribute('class', 'flowed-edge-line');
|
|
390
|
+
line.setAttribute('d', lineD(gm));
|
|
391
|
+
line.setAttribute('marker-end', 'url(#flowed-arrow)');
|
|
392
|
+
line.setAttribute('id', 'flowed-wlp-' + (++wlpSeq));
|
|
393
|
+
ge.appendChild(hit);
|
|
394
|
+
ge.appendChild(line);
|
|
395
|
+
if (guard) {
|
|
396
|
+
var wtxt = String(c.when).trim();
|
|
397
|
+
var whenEl = doc.createElementNS(svgNS, 'text');
|
|
398
|
+
whenEl.setAttribute('class', 'flowed-edge-whenlabel');
|
|
399
|
+
var tp = doc.createElementNS(svgNS, 'textPath');
|
|
400
|
+
tp.setAttribute('href', '#' + line.id);
|
|
401
|
+
tp.setAttribute('startOffset', '50%');
|
|
402
|
+
tp.setAttribute('text-anchor', 'middle');
|
|
403
|
+
var ts = doc.createElementNS(svgNS, 'tspan');
|
|
404
|
+
ts.setAttribute('dy', '-6');
|
|
405
|
+
ts.textContent = wtxt.length > 24
|
|
406
|
+
? wtxt.slice(0, 24) + '…' : wtxt;
|
|
407
|
+
tp.appendChild(ts);
|
|
408
|
+
whenEl.appendChild(tp);
|
|
409
|
+
ge.appendChild(whenEl);
|
|
410
|
+
}
|
|
411
|
+
ge.addEventListener('pointerdown', function (ev) {
|
|
412
|
+
ev.stopPropagation();
|
|
413
|
+
selectEdge(ge);
|
|
414
|
+
});
|
|
415
|
+
svg.appendChild(ge);
|
|
416
|
+
if (c.from === CANVAS_IN || c.to === CANVAS_OUT
|
|
417
|
+
|| c.from === CANVAS_OUT || c.to === CANVAS_IN) {
|
|
418
|
+
boundEdgeEls.push({ c: c, ge: ge, gm: gm });
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
function syncBound() {
|
|
423
|
+
boundEdgeEls.forEach(function (b) {
|
|
424
|
+
var aA = anchorPt(b.c.from, true);
|
|
425
|
+
var aB = anchorPt(b.c.to, false);
|
|
426
|
+
if (!aA || !aB) return;
|
|
427
|
+
var lm = lane[keyOf(b.c)];
|
|
428
|
+
if (lm != null) aA.bowMul = lm;
|
|
429
|
+
b.gm.pa = aA; b.gm.pb = aB; b.gm.c = controls(aA, aB);
|
|
430
|
+
var d = b.gm.d = pathC(aA, b.gm.c, aB);
|
|
431
|
+
var ld = lineD(b.gm);
|
|
432
|
+
b.ge.querySelector('.flowed-edge-hit').setAttribute('d', d);
|
|
433
|
+
var ln = b.ge.querySelector('.flowed-edge-line');
|
|
434
|
+
ln.setAttribute('d', ld);
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/* ---------- 查看交互:平移 / 缩放 / 适配 / 只读选择 ---------- */
|
|
439
|
+
var selNode = null, selEdge = null, card = null;
|
|
440
|
+
function selectNode(id) {
|
|
441
|
+
if (selNode) nodeEls[selNode].classList.remove('selected');
|
|
442
|
+
if (selEdge) { selEdge.classList.remove('selected'); selEdge = null; }
|
|
443
|
+
selNode = id;
|
|
444
|
+
if (id) nodeEls[id].classList.add('selected');
|
|
445
|
+
}
|
|
446
|
+
function selectEdge(ge) {
|
|
447
|
+
if (selEdge) selEdge.classList.remove('selected');
|
|
448
|
+
if (selNode) {
|
|
449
|
+
nodeEls[selNode].classList.remove('selected');
|
|
450
|
+
selNode = null;
|
|
451
|
+
}
|
|
452
|
+
selEdge = ge;
|
|
453
|
+
ge.classList.add('selected');
|
|
454
|
+
}
|
|
455
|
+
function closeCard() {
|
|
456
|
+
if (card) { card.parentNode.removeChild(card); card = null; }
|
|
457
|
+
}
|
|
458
|
+
function esc(el) {
|
|
459
|
+
return String(el).replace(/&/g, '&').replace(/</g, '<')
|
|
460
|
+
.replace(/>/g, '>').replace(/"/g, '"');
|
|
461
|
+
}
|
|
462
|
+
function field(label, val) {
|
|
463
|
+
if (val == null || val === '') return '';
|
|
464
|
+
var s = typeof val === 'string' ? val : JSON.stringify(val, null, 1);
|
|
465
|
+
return '<div><span class="k">' + esc(label) + '</span></div>'
|
|
466
|
+
+ '<pre>' + esc(s.length > 4000 ? s.slice(0, 4000) + '\n…' : s)
|
|
467
|
+
+ '</pre>';
|
|
468
|
+
}
|
|
469
|
+
function openCard(n) {
|
|
470
|
+
closeCard();
|
|
471
|
+
card = doc.createElement('div');
|
|
472
|
+
card.className = 'flowed-card';
|
|
473
|
+
var ins = conns.filter(function (c) { return c.to === n.id; })
|
|
474
|
+
.map(function (c) { return c.from + (c.when ? '(' + c.when + ')' : ''); });
|
|
475
|
+
var outs = conns.filter(function (c) { return c.from === n.id; })
|
|
476
|
+
.map(function (c) { return c.to + (c.when ? '(' + c.when + ')' : ''); });
|
|
477
|
+
card.innerHTML = '<h4><span class="flowed-node-type t-' + esc(n.type)
|
|
478
|
+
+ '">' + esc(n.tag || TYPE_LABELS[n.type] || n.type)
|
|
479
|
+
+ '</span>' + esc(n.id)
|
|
480
|
+
+ '<button class="flowed-card-close" aria-label="关闭">×</button></h4>'
|
|
481
|
+
+ field('tool', n.tool)
|
|
482
|
+
+ field('args', n.args)
|
|
483
|
+
+ field('prompt', n.prompt)
|
|
484
|
+
+ field('answer', n.answer)
|
|
485
|
+
+ field('code', n.code)
|
|
486
|
+
+ ((n.temperature != null || n.max_tokens != null)
|
|
487
|
+
? '<div><span class="k">参数</span> '
|
|
488
|
+
+ 'temperature=' + esc(n.temperature != null ? n.temperature : '—')
|
|
489
|
+
+ ' · max_tokens=' + esc(n.max_tokens != null ? n.max_tokens : '—')
|
|
490
|
+
+ (n.output ? ' · output=' + esc(n.output) : '') + '</div>' : '')
|
|
491
|
+
+ field('入边', ins.join('、')) + field('出边', outs.join('、'));
|
|
492
|
+
card.querySelector('.flowed-card-close')
|
|
493
|
+
.addEventListener('click', closeCard);
|
|
494
|
+
canvas.appendChild(card);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
canvas.addEventListener('pointerdown', function (ev) {
|
|
498
|
+
if (ev.target && ev.target.closest
|
|
499
|
+
&& ev.target.closest('.flowed-node,.flowed-edge,.flowed-card')) {
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
canvas.setPointerCapture(ev.pointerId);
|
|
503
|
+
var sx = ev.clientX - panX, sy = ev.clientY - panY;
|
|
504
|
+
function mv(e2) {
|
|
505
|
+
panX = e2.clientX - sx;
|
|
506
|
+
panY = e2.clientY - sy;
|
|
507
|
+
applyTransform();
|
|
508
|
+
}
|
|
509
|
+
function up() {
|
|
510
|
+
canvas.removeEventListener('pointermove', mv);
|
|
511
|
+
canvas.removeEventListener('pointerup', up);
|
|
512
|
+
}
|
|
513
|
+
canvas.addEventListener('pointermove', mv);
|
|
514
|
+
canvas.addEventListener('pointerup', up);
|
|
515
|
+
});
|
|
516
|
+
canvas.addEventListener('wheel', function (ev) {
|
|
517
|
+
ev.preventDefault();
|
|
518
|
+
var r = canvas.getBoundingClientRect();
|
|
519
|
+
var cx = ev.clientX - r.left, cy = ev.clientY - r.top;
|
|
520
|
+
var nz = Math.max(0.2, Math.min(2.5,
|
|
521
|
+
zoom * (ev.deltaY < 0 ? 1.1 : 0.9)));
|
|
522
|
+
var wx = (cx - panX) / zoom, wy = (cy - panY) / zoom;
|
|
523
|
+
zoom = nz;
|
|
524
|
+
panX = cx - wx * zoom;
|
|
525
|
+
panY = cy - wy * zoom;
|
|
526
|
+
applyTransform();
|
|
527
|
+
}, { passive: false });
|
|
528
|
+
|
|
529
|
+
function fit() {
|
|
530
|
+
var r = canvas.getBoundingClientRect();
|
|
531
|
+
var z = Math.min(1.4, Math.min(
|
|
532
|
+
(r.width - 60) / Math.max(200, maxX - minX),
|
|
533
|
+
(r.height - 20) / Math.max(140, maxY - minY)));
|
|
534
|
+
z = Math.max(0.2, z);
|
|
535
|
+
panX = (r.width - (maxX - minX) * z) / 2 - minX * z;
|
|
536
|
+
panY = (r.height - (maxY - minY) * z) / 2 - minY * z;
|
|
537
|
+
zoom = z;
|
|
538
|
+
applyTransform();
|
|
539
|
+
}
|
|
540
|
+
canvas.addEventListener('dblclick', function (ev) {
|
|
541
|
+
if (ev.target && ev.target.closest
|
|
542
|
+
&& ev.target.closest('.flowed-node,.flowed-edge,.flowed-card')) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
fit();
|
|
546
|
+
});
|
|
547
|
+
Object.keys(nodeEls).forEach(function (id) {
|
|
548
|
+
nodeEls[id].addEventListener('pointerdown', function (ev) {
|
|
549
|
+
ev.stopPropagation();
|
|
550
|
+
selectNode(id);
|
|
551
|
+
});
|
|
552
|
+
nodeEls[id].addEventListener('dblclick', function (ev) {
|
|
553
|
+
ev.stopPropagation();
|
|
554
|
+
selectNode(id);
|
|
555
|
+
openCard(byId[id]);
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
window.addEventListener('keydown', function (ev) {
|
|
559
|
+
if (ev.key === 'Escape') {
|
|
560
|
+
closeCard();
|
|
561
|
+
selectNode(null);
|
|
562
|
+
if (selEdge) { selEdge.classList.remove('selected'); selEdge = null; }
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
applyTransform();
|
|
567
|
+
requestAnimationFrame(function () { requestAnimationFrame(fit); });
|
|
568
|
+
if (typeof ctx.ready === 'function') ctx.ready();
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/* 守卫形注册(主文档无 Work 全局;WorkView 沙箱内有) */
|
|
572
|
+
if (typeof Work !== 'undefined' && Work && typeof Work.register === 'function') {
|
|
573
|
+
Work.register({ mount: mount });
|
|
574
|
+
}
|
|
575
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"status":"ok","item":{"id":3095,"ref":"WORKS-3095","name":"V4 幻灯片放映方案","tags":"幻灯片,deck,AI生成","image_url":"","thumb_url":"","emoji":"🎞️","status":0,"visible_to":[{"id":1,"username":"root"}],"is_pinned":false,"is_locked":false,"ban_hidden":false,"author":"AI 幻灯片工坊","author_id":1188,"author_username":"deck_forge","author_avatar":"emoji:🎬","view_count":40,"like_count":0,"favorite_count":1,"fork_count":0,"referenced_count":0,"latest_version":2,"default_version":2,"forked_from_ref":"","fork_base_version":0,"description":"让 380_V4 作品适配当前幻灯片播放条件,逐页拆解关键要点。","description_truncated":false,"description_next_offset":32,"brief":"让 380_V4 作品适配当前幻灯片播放条件,逐页拆解关键要点。","created_at":"2026-10-04T17:18:43.456006+08:00","last_published_at":"2026-10-04T17:18:45.341074+08:00","updated_at":"2026-10-04T17:18:45.339584+08:00","code_url":"/api/works/works/3095/version/2/js","has_code":true,"view":{"kind":"code"},"launch":{"type":"runtime","runtime":{"contract":"work-v1","work_ref":"WORKS-3095","code_url":"/api/works/works/3095/version/2/js","caps_url":"","decorator":""}},"item_type":"works","co_owned":true,"view_granted":true,"delivery_adopted":null,"delivery_published":null,"is_favorited":true,"references":[],"attachments":[],"mcp_declared":false}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"liked":false,"favorited":true}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"status":"ok","item":{"id":3267,"ref":"WORKS-3267","name":"组合智能体工坊","tags":"工作流,组合管线","image_url":"","thumb_url":"","emoji":"🏗️","status":0,"visible_to":[],"is_pinned":false,"is_locked":false,"ban_hidden":false,"author":"站长","author_id":1,"author_username":"root","author_avatar":"emoji:🦔","view_count":58,"like_count":0,"favorite_count":1,"fork_count":0,"referenced_count":0,"latest_version":1,"default_version":1,"forked_from_ref":"","fork_base_version":0,"description":"[TOC]\n\n# 组合智能体工坊\n\n## 用法\n\n顶图点击进入工坊:节点 = 作品;发布 = 换目标作品 WORKFLOW-SOURCE 分节(服务端闸就地报错)。\n\n## 数据\n\n```pipeline 围栏 = 当前工作副本;工坊草稿走文档版本链。\n\n```workflow-decl\n{\"kit\": \"WORKS-3266@1\"}\n```\n\n```workflow\n{\"v\": 3, \"name\": \"combo-workbench\", \"nodes\": [{\"id\": \"in\", \"type\": \"input\", \"label\": \"入口\", \"x\": 40, \"y\": 100}, {\"id\": \"out\", \"type\": \"output\", \"label\": \"出口\", \"x\": 320, \"y\": 100}], \"edges\": [{\"from\": \"in\", \"to\": \"out\"}]}\n```\n\n```pipeline\n{\"name\": \"lol_intro_full\", \"pipeline\": [{\"graph\": \"WORKS-3138@2\", \"name\": \"话题拆解\"}, {\"map\": {\"text\": \"reply\"}}, {\"graph\": \"WORKS-3227@1\", \"name\": \"逐题检索\"}, {\"map\": {\"text\": \"material\"}}, {\"graph\": \"WORKS-3228@1\", \"name\": \"成稿\"}, {\"map\": {\"text\": \"md\"}}, {\"graph\": \"WORKS-3235@1\", \"name\": \"白模装填\"}, {\"graph\": \"WORKS-3236@1\", \"name\": \"编号萃取\"}, {\"graph\": \"WORKS-3237@1\", \"name\": \"瑞士风成片\"}]}\n```","description_truncated":false,"description_next_offset":808,"brief":"白板到复合智能体:管线声明编辑台","created_at":"2026-10-05T19:13:06.297187+08:00","last_published_at":"2026-10-05T19:13:06.314182+08:00","updated_at":"2026-10-05T19:13:06.312915+08:00","code_url":"","has_code":false,"view":{"kind":"code"},"launch":{"type":"runtime","runtime":{"contract":"work-v1","work_ref":"WORKS-3267","code_url":"","caps_url":"","decorator":""}},"item_type":"works","delivery_adopted":null,"delivery_published":null,"is_favorited":true,"references":[{"ref":"WORKS-3266","name":"组合管线工坊套件","kind":"works","version":1,"follow":false,"work_version":1,"created_at":"2026-10-05T19:13:06.336410+08:00"}],"attachments":[],"mcp_declared":false}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"liked":false,"favorited":true}
|