femo-plugin 1.0.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 +201 -0
- package/README.md +627 -0
- package/femo2host/__init__.py +4 -0
- package/femo2host/femoToolcall/chronica.py +156 -0
- package/femo2host/femoToolcall/femo-chat.mjs +69 -0
- package/femo2host/femoToolcall/femo_debugger.py +1515 -0
- package/femo2host/femo_api.py +437 -0
- package/femo2host/femo_gen_api.jsx +77 -0
- package/femoBridges/ContextExample.py +555 -0
- package/femoBridges/MemoryExample.py +163 -0
- package/femoBridges/__init__.py +1 -0
- package/femoBridges/getDir/get_dir.py +56 -0
- package/femoBridges/getDir//344/275/240/345/217/257/344/273/245/350/256/276/345/256/232/344/273/273/346/204/217/346/226/207/344/273/266/345/244/271/344/270/272/347/224/250/346/210/267/346/225/260/346/215/256/346/226/207/344/273/266/345/244/271.txt +10 -0
- package/femoBridges/llmBridge.py +247 -0
- package/femoBridges/llmProviders.py +308 -0
- package/femoCompiler/FEMO_CLIrenderer.py +198 -0
- package/femoCompiler/FEMO_config.py +35 -0
- package/femoCompiler/FEMO_errors.py +278 -0
- package/femoCompiler/FEMO_interpreter.py +163 -0
- package/femoCompiler/FEMO_normalizer.py +396 -0
- package/femoCompiler/FEMO_parser.py +2468 -0
- package/femoCompiler/FEMO_runtime.py +3630 -0
- package/femoCompiler/FEMO_scope_resolver.py +209 -0
- package/femoCompiler/__init__.py +1 -0
- package/femoCompiler/actor_resolver.py +86 -0
- package/femoCompiler/block_collector.py +441 -0
- package/femoCompiler/db_utils.py +485 -0
- package/femoCompiler/femoAsync.py +401 -0
- package/femoCompiler/host_manifest.py +68 -0
- package/femoCompiler/job_manager.py +767 -0
- package/femoCompiler/protocol.py +126 -0
- package/femoCompiler/save_dialog.py +402 -0
- package/femoCompiler/task_world.py +544 -0
- package/femoCompiler/vars/__init__.py +19 -0
- package/femoCompiler/vars/checkpoint.py +113 -0
- package/femoCompiler/vars/env.py +686 -0
- package/femoCompiler/vars/evaluator.py +567 -0
- package/femoCompiler/vars/join.py +303 -0
- package/femoCompiler/vars/merge.py +157 -0
- package/femoCompiler/vars/model.py +245 -0
- package/femoExamples/AI/345/211/252/350/247/206/351/242/221/AI/345/211/252/350/247/206/351/242/221.femo +192 -0
- package/femoExamples/AI/350/201/212/345/244/251/345/256/244/group-chat.femo +42 -0
- package/femoExamples/AI/350/201/212/345/244/251/345/256/244/random_wait_time.py +10 -0
- package/femoExamples/LuxFiat/luxfiat.femo +38 -0
- package/femoExamples/LuxFiat/wait.py +29 -0
- package/femoExamples/debug/347/245/236/345/231/250/debug/347/245/236/345/231/250.femo +222 -0
- package/femoExamples/discussion.femo +70 -0
- package/femoExamples/goal-mode.femo +23 -0
- package/femoExamples//345/270/270/347/224/250/345/267/245/345/205/267python/wait.py +29 -0
- package/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils.py +205 -0
- package/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils2.py +324 -0
- package/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200-/350/255/246/351/225/277/347/211/210.femo +544 -0
- package/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200.femo +331 -0
- package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225/undercover_utils.py +683 -0
- package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225//350/260/201/346/230/257/345/215/247/345/272/225-/350/217/234/345/270/202/345/234/272/345/261/200.femo +348 -0
- package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225//350/260/201/346/230/257/345/215/247/345/272/225.femo +392 -0
- package/femoGen/document_ch.html +2352 -0
- package/femoGen/document_en.html +2279 -0
- package/femoGen/index.html +19 -0
- package/femoGen/intro_ch.html +942 -0
- package/femoGen/intro_en.html +932 -0
- package/femoGen/package-lock.json +1698 -0
- package/femoGen/package.json +19 -0
- package/femoGen/public/character_need.ttf +0 -0
- package/femoGen/public/favicon.ico +0 -0
- package/femoGen/public/femo-logo-slogan.svg +83 -0
- package/femoGen/public/femo-logo.svg +55 -0
- package/femoGen/public/logo-fullsize.ico +0 -0
- package/femoGen/src/FemoWorAuto.jsx +5444 -0
- package/femoGen/src/actionModal.jsx +358 -0
- package/femoGen/src/bubbleOverlay.jsx +701 -0
- package/femoGen/src/canvasNodes.jsx +608 -0
- package/femoGen/src/common.jsx +715 -0
- package/femoGen/src/debugPanel.jsx +530 -0
- package/femoGen/src/faIcons.jsx +84 -0
- package/femoGen/src/femoDiagnostics.js +122 -0
- package/femoGen/src/femoFileList.jsx +357 -0
- package/femoGen/src/femoGenerator.jsx +1198 -0
- package/femoGen/src/femoLog.js +107 -0
- package/femoGen/src/femoParser.jsx +2255 -0
- package/femoGen/src/femoPreview.jsx +297 -0
- package/femoGen/src/graphBuilder.jsx +358 -0
- package/femoGen/src/libPanel.jsx +519 -0
- package/femoGen/src/main.jsx +22 -0
- package/femoGen/src/mobileView.jsx +2796 -0
- package/femoGen/src/projectPanel.jsx +529 -0
- package/femoGen/src/soulModal.jsx +162 -0
- package/femoGen/src/styles/font.css +10 -0
- package/femoGen/src/themes.js +465 -0
- package/femoGen/src/useCanvasInteraction.jsx +319 -0
- package/femoGen/vite.config.js +28 -0
- package/femoGen//347/222/207/345/255/230/346/247/221.txt +15 -0
- package/hostAdapter/dshAdapter/README.md +68 -0
- package/hostAdapter/dshAdapter/build.mjs +75 -0
- package/hostAdapter/dshAdapter/client/client-ui/chat-node.tsx +339 -0
- package/hostAdapter/dshAdapter/client/client-ui/composer.tsx +997 -0
- package/hostAdapter/dshAdapter/client/client-ui/editor-page.tsx +726 -0
- package/hostAdapter/dshAdapter/client/client-ui/editor-view.tsx +88 -0
- package/hostAdapter/dshAdapter/client/client-ui/femo-stream-live.tsx +264 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/frame-router.ts +282 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/index.ts +44 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/ledger.ts +329 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/turn-view.tsx +211 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/window-id.ts +28 -0
- package/hostAdapter/dshAdapter/client/client-ui/stream-store.ts +550 -0
- package/hostAdapter/dshAdapter/client/client-ui/styles.ts +144 -0
- package/hostAdapter/dshAdapter/client/client-ui/view-button.tsx +572 -0
- package/hostAdapter/dshAdapter/client/client-ui/view-state.ts +61 -0
- package/hostAdapter/dshAdapter/client/client.tsx +518 -0
- package/hostAdapter/dshAdapter/client/fa-icons.tsx +112 -0
- package/hostAdapter/dshAdapter/client/femo-reasoning-row.tsx +103 -0
- package/hostAdapter/dshAdapter/client/lineage-fork-native.jsx +624 -0
- package/hostAdapter/dshAdapter/client/lineage-fork.jsx +585 -0
- package/hostAdapter/dshAdapter/cordis.patch.yml +8 -0
- package/hostAdapter/dshAdapter/dshPatch/DSH-0.1.2-fork/344/277/256/346/224/271/351/234/200/346/261/202.md +184 -0
- package/hostAdapter/dshAdapter/dshPatch/MEOW_MODIFICATIONS.md +3105 -0
- package/hostAdapter/dshAdapter/dshPatch/patch-dsh-0.1.2-alpha.1.py +313 -0
- package/hostAdapter/dshAdapter/host/api-retry.ts +141 -0
- package/hostAdapter/dshAdapter/host/bridge.ts +224 -0
- package/hostAdapter/dshAdapter/host/config.ts +124 -0
- package/hostAdapter/dshAdapter/host/debug-log.ts +29 -0
- package/hostAdapter/dshAdapter/host/debug-run.ts +793 -0
- package/hostAdapter/dshAdapter/host/diag-feed.ts +56 -0
- package/hostAdapter/dshAdapter/host/engine-events.ts +891 -0
- package/hostAdapter/dshAdapter/host/engine-transcript.ts +122 -0
- package/hostAdapter/dshAdapter/host/femo-files.ts +210 -0
- package/hostAdapter/dshAdapter/host/god-mirror.ts +234 -0
- package/hostAdapter/dshAdapter/host/host-log.ts +101 -0
- package/hostAdapter/dshAdapter/host/http.ts +66 -0
- package/hostAdapter/dshAdapter/host/index.ts +633 -0
- package/hostAdapter/dshAdapter/host/list-cache.ts +183 -0
- package/hostAdapter/dshAdapter/host/main-actor.ts +853 -0
- package/hostAdapter/dshAdapter/host/main-delivery-queue.ts +115 -0
- package/hostAdapter/dshAdapter/host/native-state.ts +21 -0
- package/hostAdapter/dshAdapter/host/node-retry.ts +246 -0
- package/hostAdapter/dshAdapter/host/persona.ts +146 -0
- package/hostAdapter/dshAdapter/host/pre-step-gate.ts +95 -0
- package/hostAdapter/dshAdapter/host/proj-trace.ts +49 -0
- package/hostAdapter/dshAdapter/host/projection-input.ts +238 -0
- package/hostAdapter/dshAdapter/host/projection.ts +742 -0
- package/hostAdapter/dshAdapter/host/routes.ts +1196 -0
- package/hostAdapter/dshAdapter/host/run-control.ts +641 -0
- package/hostAdapter/dshAdapter/host/safe-steer.ts +33 -0
- package/hostAdapter/dshAdapter/host/section-gate.ts +108 -0
- package/hostAdapter/dshAdapter/host/session-events.ts +45 -0
- package/hostAdapter/dshAdapter/host/state-files.ts +301 -0
- package/hostAdapter/dshAdapter/host/stream-frames.ts +229 -0
- package/hostAdapter/dshAdapter/host/subagent-native.ts +997 -0
- package/hostAdapter/dshAdapter/host/subagent.ts +1205 -0
- package/hostAdapter/dshAdapter/host/tools.ts +486 -0
- package/hostAdapter/dshAdapter/host/windowing-native.ts +294 -0
- package/hostAdapter/dshAdapter/host.manifest.json +6 -0
- package/hostAdapter/dshAdapter/lib/client.js +19161 -0
- package/hostAdapter/dshAdapter/lib/client.js.map +7 -0
- package/hostAdapter/dshAdapter/lib/index.js +8173 -0
- package/hostAdapter/dshAdapter/lib/index.js.map +7 -0
- package/hostAdapter/dshAdapter/package-lock.json +500 -0
- package/hostAdapter/dshAdapter/package.json +55 -0
- package/hostAdapter/dshAdapter/pnpm-lock.yaml +596 -0
- package/hostAdapter/dshAdapter/pnpm-workspace.yaml +2 -0
- package/hostAdapter/dshAdapter/python/dev-bridge-test.py +43 -0
- package/hostAdapter/dshAdapter/python/femo_bridge.py +533 -0
- package/hostAdapter/dshAdapter/tsconfig.host.json +9 -0
- package/hostAdapter/dshAdapter/tsconfig.json +21 -0
- package/package.json +40 -0
- package//350/257/255/346/263/225/346/226/207/346/241/243.md +1136 -0
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════
|
|
2
|
+
// ═══ canvasNodes.jsx ═══
|
|
3
|
+
// ═══════════════════════════════════════════════════════════════
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { PortCircle, TYPES, SPECIAL_COLORS, NW, NH, MW, MH, SPW, SPH, PSW, PSH, ti, SINK_ONLY, getNodeSize } from './common';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
function ActionNodeView({
|
|
10
|
+
node,
|
|
11
|
+
sel,
|
|
12
|
+
onBody,
|
|
13
|
+
onPortDown,
|
|
14
|
+
onPortUp,
|
|
15
|
+
onBodyMouseUp,
|
|
16
|
+
onDbl,
|
|
17
|
+
onBubbleClick,
|
|
18
|
+
nodeState,
|
|
19
|
+
isActive,
|
|
20
|
+
errorNodeIds,
|
|
21
|
+
}) {
|
|
22
|
+
const isMod = node.type === 'module';
|
|
23
|
+
const w = isMod ? MW : NW,
|
|
24
|
+
h = isMod ? MH : NH;
|
|
25
|
+
const { c } = isMod
|
|
26
|
+
? { c: 'var(--femo-tag-bg)', bg: 'var(--femo-bg-2)' }
|
|
27
|
+
: ti(node.action?.executorType);
|
|
28
|
+
// 左上角类型徽章 token key(module 用专组;executorType 不在 TYPES 里时回退 ai,与 ti 回退一致)
|
|
29
|
+
const badgeKey = isMod
|
|
30
|
+
? 'module'
|
|
31
|
+
: TYPES.some((t) => t.t === node.action?.executorType)
|
|
32
|
+
? node.action.executorType
|
|
33
|
+
: 'ai';
|
|
34
|
+
|
|
35
|
+
// 是否显示气泡:有 nodeState(运行中或已完成)时显示
|
|
36
|
+
//console.log(
|
|
37
|
+
// `[ActionNodeView] node.id="${node.id}" node.label="${node.label}" node.type="${node.type}" nodeState=`,
|
|
38
|
+
// nodeState
|
|
39
|
+
//);
|
|
40
|
+
const hasState = !!nodeState?.status;
|
|
41
|
+
const isStreaming = nodeState?.status === 'ai_streaming';
|
|
42
|
+
const isHumanWait = nodeState?.status === 'human_wait';
|
|
43
|
+
const isDone = ['ai_done', 'human_done', 'done'].includes(nodeState?.status);
|
|
44
|
+
|
|
45
|
+
const ports = {
|
|
46
|
+
top: { x: w / 2, y: 0 },
|
|
47
|
+
bottom: { x: w / 2, y: h },
|
|
48
|
+
left: { x: 0, y: h / 2 },
|
|
49
|
+
right: { x: w, y: h / 2 },
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// 呼吸灯动画样式
|
|
53
|
+
const isErrorExplicit = errorNodeIds?.has(node.id) ?? false;
|
|
54
|
+
const isError = nodeState?.status === 'error' || isErrorExplicit;
|
|
55
|
+
const glowStyle = (isActive || isError)
|
|
56
|
+
? {
|
|
57
|
+
animation: isError
|
|
58
|
+
? 'nodeGlowError 1.5s ease-in-out infinite'
|
|
59
|
+
: 'nodeGlow 1.5s ease-in-out infinite',
|
|
60
|
+
}
|
|
61
|
+
: {};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div
|
|
65
|
+
data-node-id={node.id}
|
|
66
|
+
onMouseDown={onBody}
|
|
67
|
+
onMouseUp={onBodyMouseUp}
|
|
68
|
+
onDoubleClick={onDbl}
|
|
69
|
+
style={{
|
|
70
|
+
position: 'absolute',
|
|
71
|
+
left: node.x,
|
|
72
|
+
top: node.y,
|
|
73
|
+
width: w,
|
|
74
|
+
height: h,
|
|
75
|
+
background: 'var(--femo-node-bg)',
|
|
76
|
+
borderRadius: 'var(--femo-radius-lg)',
|
|
77
|
+
border: `var(--femo-node-border-w) solid ${sel ? c : 'var(--femo-node-border)'}`,
|
|
78
|
+
boxShadow: sel
|
|
79
|
+
? `0 0 0 3px color-mix(in srgb, ${c} 13%, transparent), var(--femo-node-shadow-sel)`
|
|
80
|
+
: 'var(--femo-node-shadow-rest)',
|
|
81
|
+
cursor: 'grab',
|
|
82
|
+
userSelect: 'none',
|
|
83
|
+
transition: 'border-color 0.12s, box-shadow 0.12s',
|
|
84
|
+
zIndex: sel ? 20 : 2,
|
|
85
|
+
fontFamily: 'var(--femo-font-sans)',
|
|
86
|
+
...glowStyle,
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
<div style={{ padding: '10px 12px 9px' }}>
|
|
90
|
+
{/* 行1:类型芯片 + 执行者(执行者名字一般不长,放得下) */}
|
|
91
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 3, minWidth: 0, minHeight: 15 }}>
|
|
92
|
+
<span
|
|
93
|
+
style={{
|
|
94
|
+
background: `var(--femo-badge-bg-${badgeKey})`,
|
|
95
|
+
color: `var(--femo-badge-fg-${badgeKey})`,
|
|
96
|
+
borderRadius: 'var(--femo-radius-xs)',
|
|
97
|
+
padding: '1px 5px',
|
|
98
|
+
fontSize: 8.5,
|
|
99
|
+
fontWeight: 800,
|
|
100
|
+
letterSpacing: '0.04em',
|
|
101
|
+
fontFamily: 'var(--femo-font-mono)',
|
|
102
|
+
lineHeight: 1.4,
|
|
103
|
+
flexShrink: 0,
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
{isMod ? 'module' : node.action?.executorType || 'ai'}
|
|
107
|
+
</span>
|
|
108
|
+
{!isMod && node.action?.executorActor ? (
|
|
109
|
+
<span
|
|
110
|
+
style={{
|
|
111
|
+
fontSize: 10,
|
|
112
|
+
color: 'var(--femo-neutral)',
|
|
113
|
+
fontFamily: 'var(--femo-font-mono)',
|
|
114
|
+
marginLeft: 'auto',
|
|
115
|
+
overflow: 'hidden',
|
|
116
|
+
textOverflow: 'ellipsis',
|
|
117
|
+
whiteSpace: 'nowrap',
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
{node.action.executorActor}
|
|
121
|
+
</span>
|
|
122
|
+
) : null}
|
|
123
|
+
</div>
|
|
124
|
+
{/* 行2:action 名独占整行(节点 label 与 action 名同步,显示 action 名即节点名) */}
|
|
125
|
+
<div
|
|
126
|
+
style={{
|
|
127
|
+
fontSize: 12.5,
|
|
128
|
+
fontWeight: 700,
|
|
129
|
+
color: 'var(--femo-text-1)',
|
|
130
|
+
overflow: 'hidden',
|
|
131
|
+
textOverflow: 'ellipsis',
|
|
132
|
+
whiteSpace: 'nowrap',
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
{isMod ? `&${node.modRef || 'Module'}` : node.action?.name || '未命名'}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
{/* 小气泡 - 有状态时自动显示,运行完不消失(data-bubble-node:手机端触摸仲裁识别用) */}
|
|
146
|
+
{hasState && node.type === 'action' && (
|
|
147
|
+
<div
|
|
148
|
+
data-bubble-node={node.id}
|
|
149
|
+
onClick={(e) => {
|
|
150
|
+
e.stopPropagation();
|
|
151
|
+
onBubbleClick && onBubbleClick(node.id);
|
|
152
|
+
}}
|
|
153
|
+
style={{
|
|
154
|
+
position: 'absolute',
|
|
155
|
+
top: -28,
|
|
156
|
+
right: -8,
|
|
157
|
+
maxWidth: 180,
|
|
158
|
+
minWidth: 32,
|
|
159
|
+
background: isStreaming ? 'var(--femo-primary-soft-2)' : isHumanWait ? 'var(--femo-warning-soft)' : 'var(--femo-success-soft)',
|
|
160
|
+
borderRadius: 'var(--femo-radius-bubble)',
|
|
161
|
+
border: `var(--femo-border-w-strong) solid ${isStreaming ? c : isHumanWait ? 'var(--femo-warning)' : 'var(--femo-success)'}`,
|
|
162
|
+
display: 'flex',
|
|
163
|
+
alignItems: 'center',
|
|
164
|
+
cursor: 'pointer',
|
|
165
|
+
zIndex: 5,
|
|
166
|
+
boxShadow: '0 2px 8px var(--femo-shadow-sm)',
|
|
167
|
+
padding: '3px 8px',
|
|
168
|
+
overflow: 'hidden',
|
|
169
|
+
transition: 'all 0.2s ease',
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
{isStreaming ? (
|
|
173
|
+
<span
|
|
174
|
+
style={{
|
|
175
|
+
fontSize: 10,
|
|
176
|
+
color: 'var(--femo-text-1)',
|
|
177
|
+
whiteSpace: 'nowrap',
|
|
178
|
+
overflow: 'hidden',
|
|
179
|
+
textOverflow: 'ellipsis',
|
|
180
|
+
maxWidth: 160,
|
|
181
|
+
lineHeight: '14px',
|
|
182
|
+
}}
|
|
183
|
+
>
|
|
184
|
+
{nodeState.streamingText?.slice(-30) || '...'}
|
|
185
|
+
<span style={{ animation: 'blink 0.7s infinite' }}>|</span>
|
|
186
|
+
</span>
|
|
187
|
+
) : isHumanWait ? (
|
|
188
|
+
<span style={{ fontSize: 10, color: 'var(--femo-warning)', fontWeight: 600, whiteSpace: 'nowrap' }}>
|
|
189
|
+
⏳ 等待输入
|
|
190
|
+
</span>
|
|
191
|
+
) : isDone ? (
|
|
192
|
+
<span
|
|
193
|
+
style={{
|
|
194
|
+
fontSize: 10,
|
|
195
|
+
color: 'var(--femo-success-text)',
|
|
196
|
+
whiteSpace: 'nowrap',
|
|
197
|
+
overflow: 'hidden',
|
|
198
|
+
textOverflow: 'ellipsis',
|
|
199
|
+
maxWidth: 160,
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
{typeof nodeState.output === 'string'
|
|
203
|
+
? nodeState.output.length > 20
|
|
204
|
+
? nodeState.output.slice(0, 20) + '...'
|
|
205
|
+
: nodeState.output
|
|
206
|
+
: '✓ 完成'}
|
|
207
|
+
</span>
|
|
208
|
+
) : (
|
|
209
|
+
<span style={{ fontSize: 10, color: c, fontWeight: 600 }}>运行中...</span>
|
|
210
|
+
)}
|
|
211
|
+
</div>
|
|
212
|
+
)}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
{/* 4 Ports */}
|
|
223
|
+
{sel && (
|
|
224
|
+
<>
|
|
225
|
+
<PortCircle
|
|
226
|
+
x={ports.top.x}
|
|
227
|
+
y={ports.top.y}
|
|
228
|
+
color={c}
|
|
229
|
+
nodeId={node.id} portDir="top"
|
|
230
|
+
portX={node.x + w/2} portY={node.y}
|
|
231
|
+
onMouseDown={(e) => onPortDown(e, 'top', node.x + w/2, node.y)}
|
|
232
|
+
onMouseUp={(e) => onPortUp(e, 'top', node.x + w/2, node.y)}
|
|
233
|
+
/>
|
|
234
|
+
<PortCircle
|
|
235
|
+
x={ports.bottom.x}
|
|
236
|
+
y={ports.bottom.y}
|
|
237
|
+
color={c}
|
|
238
|
+
nodeId={node.id} portDir="bottom"
|
|
239
|
+
onMouseDown={(e) => onPortDown(e, 'bottom')}
|
|
240
|
+
onMouseUp={(e) => onPortUp(e, 'bottom')}
|
|
241
|
+
/>
|
|
242
|
+
<PortCircle
|
|
243
|
+
x={ports.left.x}
|
|
244
|
+
y={ports.left.y}
|
|
245
|
+
color={c}
|
|
246
|
+
nodeId={node.id} portDir="left"
|
|
247
|
+
onMouseDown={(e) => onPortDown(e, 'left')}
|
|
248
|
+
onMouseUp={(e) => onPortUp(e, 'left')}
|
|
249
|
+
/>
|
|
250
|
+
<PortCircle
|
|
251
|
+
x={ports.right.x}
|
|
252
|
+
y={ports.right.y}
|
|
253
|
+
color={c}
|
|
254
|
+
nodeId={node.id} portDir="right"
|
|
255
|
+
onMouseDown={(e) => onPortDown(e, 'right')}
|
|
256
|
+
onMouseUp={(e) => onPortUp(e, 'right')}
|
|
257
|
+
/>
|
|
258
|
+
</>
|
|
259
|
+
)}
|
|
260
|
+
</div>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
function PositionNodeView({
|
|
266
|
+
node,
|
|
267
|
+
sel,
|
|
268
|
+
onBody,
|
|
269
|
+
onPortDown,
|
|
270
|
+
onPortUp,
|
|
271
|
+
onBodyMouseUp,
|
|
272
|
+
}) {
|
|
273
|
+
const w = PSW,
|
|
274
|
+
h = PSH;
|
|
275
|
+
const c = 'var(--femo-text-2)',
|
|
276
|
+
bg = 'var(--femo-bg)';
|
|
277
|
+
const border = sel ? c : 'var(--femo-tag-bg)';
|
|
278
|
+
|
|
279
|
+
const ports = {
|
|
280
|
+
top: { x: w / 2, y: 0 },
|
|
281
|
+
bottom: { x: w / 2, y: h },
|
|
282
|
+
left: { x: 0, y: h / 2 },
|
|
283
|
+
right: { x: w, y: h / 2 },
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
return (
|
|
287
|
+
<div
|
|
288
|
+
onMouseDown={onBody}
|
|
289
|
+
onMouseUp={onBodyMouseUp}
|
|
290
|
+
style={{
|
|
291
|
+
position: 'absolute',
|
|
292
|
+
left: node.x,
|
|
293
|
+
top: node.y,
|
|
294
|
+
width: w,
|
|
295
|
+
height: h,
|
|
296
|
+
background: bg,
|
|
297
|
+
borderRadius: 'var(--femo-radius-xl)',
|
|
298
|
+
border: `var(--femo-border-w-selected) solid ${border}`,
|
|
299
|
+
boxShadow: sel
|
|
300
|
+
? `0 0 0 3px color-mix(in srgb, ${c} 13%, transparent), var(--femo-node-shadow-sel-sm)`
|
|
301
|
+
: 'var(--femo-node-shadow-rest-sm)',
|
|
302
|
+
cursor: 'grab',
|
|
303
|
+
userSelect: 'none',
|
|
304
|
+
transition: 'border-color 0.12s, box-shadow 0.12s',
|
|
305
|
+
zIndex: sel ? 20 : 2,
|
|
306
|
+
display: 'flex',
|
|
307
|
+
alignItems: 'center',
|
|
308
|
+
justifyContent: 'center',
|
|
309
|
+
fontFamily: 'var(--femo-font-mono)',
|
|
310
|
+
}}
|
|
311
|
+
>
|
|
312
|
+
<span
|
|
313
|
+
style={{
|
|
314
|
+
fontSize: 10,
|
|
315
|
+
fontWeight: 800,
|
|
316
|
+
color: c,
|
|
317
|
+
letterSpacing: '0.06em',
|
|
318
|
+
}}
|
|
319
|
+
>
|
|
320
|
+
{node.label.replace(/[\[\]]/g, '')}
|
|
321
|
+
</span>
|
|
322
|
+
|
|
323
|
+
{sel && (
|
|
324
|
+
<>
|
|
325
|
+
<PortCircle
|
|
326
|
+
x={ports.top.x}
|
|
327
|
+
y={ports.top.y}
|
|
328
|
+
color={c}
|
|
329
|
+
onMouseDown={(e) => onPortDown(e, 'top')}
|
|
330
|
+
onMouseUp={(e) => onPortUp(e, 'top')}
|
|
331
|
+
/>
|
|
332
|
+
<PortCircle
|
|
333
|
+
x={ports.bottom.x}
|
|
334
|
+
y={ports.bottom.y}
|
|
335
|
+
color={c}
|
|
336
|
+
onMouseDown={(e) => onPortDown(e, 'bottom')}
|
|
337
|
+
onMouseUp={(e) => onPortUp(e, 'bottom')}
|
|
338
|
+
/>
|
|
339
|
+
<PortCircle
|
|
340
|
+
x={ports.left.x}
|
|
341
|
+
y={ports.left.y}
|
|
342
|
+
color={c}
|
|
343
|
+
onMouseDown={(e) => onPortDown(e, 'left')}
|
|
344
|
+
onMouseUp={(e) => onPortUp(e, 'left')}
|
|
345
|
+
/>
|
|
346
|
+
<PortCircle
|
|
347
|
+
x={ports.right.x}
|
|
348
|
+
y={ports.right.y}
|
|
349
|
+
color={c}
|
|
350
|
+
onMouseDown={(e) => onPortDown(e, 'right')}
|
|
351
|
+
onMouseUp={(e) => onPortUp(e, 'right')}
|
|
352
|
+
/>
|
|
353
|
+
</>
|
|
354
|
+
)}
|
|
355
|
+
</div>
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
function SpecialNodeView({
|
|
361
|
+
node,
|
|
362
|
+
sel,
|
|
363
|
+
onBody,
|
|
364
|
+
onPortDown,
|
|
365
|
+
onPortUp,
|
|
366
|
+
onBodyMouseUp,
|
|
367
|
+
isActive = false,
|
|
368
|
+
}) {
|
|
369
|
+
const sc = SPECIAL_COLORS[node.specialType] || SPECIAL_COLORS.START;
|
|
370
|
+
const size = getNodeSize(node);
|
|
371
|
+
const w = size.w,
|
|
372
|
+
h = size.h;
|
|
373
|
+
const border = sc.c; // round21:特殊节点边框常显类型色(未选中细一号,选中加粗+光环)
|
|
374
|
+
// round22:未选中边框与 node-bg 各半混合——灰度对齐金边框档位,色相保留;选中恢复鲜亮原色
|
|
375
|
+
const borderDim = `color-mix(in srgb, ${sc.c} 50%, var(--femo-node-border-mix-base))`;
|
|
376
|
+
const isSink = SINK_ONLY.has(node.specialType);
|
|
377
|
+
|
|
378
|
+
const ports = {
|
|
379
|
+
top: { x: w / 2, y: 0 },
|
|
380
|
+
bottom: { x: w / 2, y: h },
|
|
381
|
+
left: { x: 0, y: h / 2 },
|
|
382
|
+
right: { x: w, y: h / 2 },
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
return (
|
|
386
|
+
<div
|
|
387
|
+
data-node-id={node.id}
|
|
388
|
+
onMouseDown={onBody}
|
|
389
|
+
onMouseUp={onBodyMouseUp}
|
|
390
|
+
style={{
|
|
391
|
+
position: 'absolute',
|
|
392
|
+
left: node.x,
|
|
393
|
+
top: node.y,
|
|
394
|
+
width: w,
|
|
395
|
+
height: h,
|
|
396
|
+
background: sc.bg,
|
|
397
|
+
borderRadius: 'var(--femo-radius-xl)',
|
|
398
|
+
border: sel
|
|
399
|
+
? `var(--femo-border-w-selected) solid ${border}`
|
|
400
|
+
: `var(--femo-border-w) solid ${borderDim}`,
|
|
401
|
+
boxShadow: isActive
|
|
402
|
+
? `0 0 12px 4px ${sc.c}66, 0 0 24px 8px ${sc.c}33`
|
|
403
|
+
: sel
|
|
404
|
+
? `0 0 0 3px color-mix(in srgb, ${sc.c} 13%, transparent), var(--femo-node-shadow-sel-sm)`
|
|
405
|
+
: 'var(--femo-node-shadow-rest-sm)',
|
|
406
|
+
animation: isActive ? 'nodeGlow 1.5s ease-in-out infinite' : 'none',
|
|
407
|
+
cursor: 'grab',
|
|
408
|
+
userSelect: 'none',
|
|
409
|
+
transition: 'border-color 0.12s, box-shadow 0.12s',
|
|
410
|
+
zIndex: sel ? 20 : 2,
|
|
411
|
+
display: 'flex',
|
|
412
|
+
alignItems: 'center',
|
|
413
|
+
justifyContent: 'center',
|
|
414
|
+
fontFamily: 'var(--femo-font-mono)',
|
|
415
|
+
}}
|
|
416
|
+
>
|
|
417
|
+
<span
|
|
418
|
+
className="femo-special-label"
|
|
419
|
+
style={{
|
|
420
|
+
fontSize: 11,
|
|
421
|
+
fontWeight: 800,
|
|
422
|
+
color: sc.c,
|
|
423
|
+
letterSpacing: '0.06em',
|
|
424
|
+
}}
|
|
425
|
+
>
|
|
426
|
+
{node.specialType}
|
|
427
|
+
</span>
|
|
428
|
+
|
|
429
|
+
{sel && !isSink && (
|
|
430
|
+
<>
|
|
431
|
+
<PortCircle
|
|
432
|
+
x={ports.top.x} y={ports.top.y} color={sc.c}
|
|
433
|
+
nodeId={node.id} portDir="top"
|
|
434
|
+
onMouseDown={(e) => onPortDown(e, 'top')}
|
|
435
|
+
onMouseUp={(e) => onPortUp(e, 'top')}
|
|
436
|
+
/>
|
|
437
|
+
<PortCircle
|
|
438
|
+
x={ports.bottom.x} y={ports.bottom.y} color={sc.c}
|
|
439
|
+
nodeId={node.id} portDir="bottom"
|
|
440
|
+
onMouseDown={(e) => onPortDown(e, 'bottom')}
|
|
441
|
+
onMouseUp={(e) => onPortUp(e, 'bottom')}
|
|
442
|
+
/>
|
|
443
|
+
<PortCircle
|
|
444
|
+
x={ports.left.x} y={ports.left.y} color={sc.c}
|
|
445
|
+
nodeId={node.id} portDir="left"
|
|
446
|
+
onMouseDown={(e) => onPortDown(e, 'left')}
|
|
447
|
+
onMouseUp={(e) => onPortUp(e, 'left')}
|
|
448
|
+
/>
|
|
449
|
+
<PortCircle
|
|
450
|
+
x={ports.right.x} y={ports.right.y} color={sc.c}
|
|
451
|
+
nodeId={node.id} portDir="right"
|
|
452
|
+
onMouseDown={(e) => onPortDown(e, 'right')}
|
|
453
|
+
onMouseUp={(e) => onPortUp(e, 'right')}
|
|
454
|
+
/>
|
|
455
|
+
</>
|
|
456
|
+
)}
|
|
457
|
+
</div>
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
function ForOutNodeView({ node, sel, onBodyMouseUp, onBubbleClick, onPortDown, onPortUp, forSpecialType = 'FOR' }) {
|
|
464
|
+
const sc = SPECIAL_COLORS[forSpecialType] || SPECIAL_COLORS.FOR;
|
|
465
|
+
const w = 22, h = 22;
|
|
466
|
+
const centerX = node.x + w / 2;
|
|
467
|
+
const centerY = node.y + h / 2;
|
|
468
|
+
|
|
469
|
+
const handleMouseDown = (e) => {
|
|
470
|
+
if (onPortDown) {
|
|
471
|
+
onPortDown(e, 'center', centerX, centerY);
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
const handleMouseUp = (e) => {
|
|
476
|
+
if (onPortUp) {
|
|
477
|
+
onPortUp(e, 'center', centerX, centerY);
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
const handleClick = (e) => {
|
|
482
|
+
e.stopPropagation();
|
|
483
|
+
onBubbleClick && onBubbleClick(node.id);
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
return (
|
|
487
|
+
<div
|
|
488
|
+
onMouseDown={handleMouseDown}
|
|
489
|
+
onMouseUp={handleMouseUp}
|
|
490
|
+
onClick={handleClick}
|
|
491
|
+
style={{
|
|
492
|
+
position: 'absolute',
|
|
493
|
+
left: node.x,
|
|
494
|
+
top: node.y,
|
|
495
|
+
width: w,
|
|
496
|
+
height: h,
|
|
497
|
+
borderRadius: 'var(--femo-radius-pill)',
|
|
498
|
+
background: sc.bg,
|
|
499
|
+
border: `${sel ? 2.5 : 1.5}px solid ${sc.c}`, // 👈 只有选中才变粗
|
|
500
|
+
display: 'flex',
|
|
501
|
+
alignItems: 'center',
|
|
502
|
+
justifyContent: 'center',
|
|
503
|
+
fontSize: 9,
|
|
504
|
+
fontWeight: 800,
|
|
505
|
+
color: sc.c,
|
|
506
|
+
fontFamily: 'var(--femo-font-mono)',
|
|
507
|
+
cursor: sel ? 'grabbing' : 'crosshair',
|
|
508
|
+
userSelect: 'none',
|
|
509
|
+
zIndex: 23,
|
|
510
|
+
boxShadow: sel ? `0 0 0 3px ${sc.c}44, 0 0 12px ${sc.c}55` : 'none',
|
|
511
|
+
transition: 'border-width 0.12s, box-shadow 0.12s',
|
|
512
|
+
}}
|
|
513
|
+
>
|
|
514
|
+
<span>出</span>
|
|
515
|
+
</div>
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
function ParOutNodeView({
|
|
521
|
+
node,
|
|
522
|
+
sel,
|
|
523
|
+
onBody,
|
|
524
|
+
onPortDown,
|
|
525
|
+
onPortUp,
|
|
526
|
+
onBodyMouseUp,
|
|
527
|
+
}) {
|
|
528
|
+
const sc = SPECIAL_COLORS['PAR'] || SPECIAL_COLORS.FOR;
|
|
529
|
+
const size = getNodeSize(node);
|
|
530
|
+
const w = size.w, h = size.h;
|
|
531
|
+
const border = sc.c; // round41:补齐 PAR_OUT 彩边(与 START/FOR/PAR 同款常显类型色)
|
|
532
|
+
|
|
533
|
+
const rightPort = { x: w, y: h / 2 };
|
|
534
|
+
|
|
535
|
+
return (
|
|
536
|
+
<div
|
|
537
|
+
onMouseDown={onBody}
|
|
538
|
+
onMouseUp={onBodyMouseUp}
|
|
539
|
+
style={{
|
|
540
|
+
position: 'absolute',
|
|
541
|
+
left: node.x,
|
|
542
|
+
top: node.y,
|
|
543
|
+
width: w,
|
|
544
|
+
height: h,
|
|
545
|
+
background: sc.bg,
|
|
546
|
+
borderRadius: 'var(--femo-radius-xl)',
|
|
547
|
+
border: `var(--femo-border-w) solid ${border}`,
|
|
548
|
+
boxShadow: sel
|
|
549
|
+
? `0 0 0 3px color-mix(in srgb, ${sc.c} 13%, transparent), var(--femo-node-shadow-sel-sm)`
|
|
550
|
+
: 'var(--femo-node-shadow-rest-sm)',
|
|
551
|
+
cursor: 'grab',
|
|
552
|
+
userSelect: 'none',
|
|
553
|
+
transition: 'border-color 0.12s, box-shadow 0.12s',
|
|
554
|
+
zIndex: sel ? 20 : 2,
|
|
555
|
+
display: 'flex',
|
|
556
|
+
alignItems: 'center',
|
|
557
|
+
justifyContent: 'center',
|
|
558
|
+
fontFamily: 'var(--femo-font-mono)',
|
|
559
|
+
}}
|
|
560
|
+
>
|
|
561
|
+
<span
|
|
562
|
+
className="femo-special-label"
|
|
563
|
+
style={{
|
|
564
|
+
fontSize: 11,
|
|
565
|
+
fontWeight: 800,
|
|
566
|
+
color: sc.c,
|
|
567
|
+
letterSpacing: '0.06em',
|
|
568
|
+
}}
|
|
569
|
+
>
|
|
570
|
+
PAR_OUT
|
|
571
|
+
</span>
|
|
572
|
+
|
|
573
|
+
{sel && (
|
|
574
|
+
<>
|
|
575
|
+
<PortCircle
|
|
576
|
+
x={w / 2}
|
|
577
|
+
y={0}
|
|
578
|
+
color={sc.c}
|
|
579
|
+
onMouseDown={(e) => onPortDown(e, 'top')}
|
|
580
|
+
onMouseUp={(e) => onPortUp(e, 'top')}
|
|
581
|
+
/>
|
|
582
|
+
<PortCircle
|
|
583
|
+
x={w / 2}
|
|
584
|
+
y={h}
|
|
585
|
+
color={sc.c}
|
|
586
|
+
onMouseDown={(e) => onPortDown(e, 'bottom')}
|
|
587
|
+
onMouseUp={(e) => onPortUp(e, 'bottom')}
|
|
588
|
+
/>
|
|
589
|
+
<PortCircle
|
|
590
|
+
x={0}
|
|
591
|
+
y={h / 2}
|
|
592
|
+
color={sc.c}
|
|
593
|
+
onMouseDown={(e) => onPortDown(e, 'left')}
|
|
594
|
+
onMouseUp={(e) => onPortUp(e, 'left')}
|
|
595
|
+
/>
|
|
596
|
+
<PortCircle
|
|
597
|
+
x={w}
|
|
598
|
+
y={h / 2}
|
|
599
|
+
color={sc.c}
|
|
600
|
+
onMouseDown={(e) => onPortDown(e, 'right')}
|
|
601
|
+
onMouseUp={(e) => onPortUp(e, 'right')}
|
|
602
|
+
/>
|
|
603
|
+
</>
|
|
604
|
+
)}
|
|
605
|
+
</div>
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
export { ActionNodeView, PositionNodeView, SpecialNodeView, ForOutNodeView, ParOutNodeView };
|