@joplo-app/core 0.2.18 → 0.3.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/actions.d.ts +6 -0
- package/dist/actions.js +34 -0
- package/dist/agent-skill.d.ts +9 -15
- package/dist/agent-skill.js +41 -44
- package/dist/auto-caption.d.ts +3 -0
- package/dist/auto-caption.js +33 -0
- package/dist/catalog.d.ts +39 -42
- package/dist/catalog.js +27 -329
- package/dist/compile.d.ts +2 -8
- package/dist/compile.js +225 -393
- package/dist/content-i18n.js +27 -16
- package/dist/feature-diff.d.ts +9 -9
- package/dist/feature-diff.js +28 -6
- package/dist/focus.d.ts +3 -1
- package/dist/focus.js +16 -34
- package/dist/guide.d.ts +10 -12
- package/dist/guide.js +363 -591
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/media.d.ts +10 -0
- package/dist/media.js +43 -0
- package/dist/node.d.ts +1 -2
- package/dist/node.js +1 -2
- package/dist/outline.js +1 -1
- package/dist/pace.d.ts +4 -1
- package/dist/pace.js +7 -3
- package/dist/player.d.ts +8 -41
- package/dist/player.js +83 -147
- package/dist/playground.d.ts +38 -0
- package/dist/playground.js +111 -0
- package/dist/plugin-data.d.ts +11 -0
- package/dist/plugin-data.js +96 -0
- package/dist/plugins/compiler.d.ts +66 -0
- package/dist/plugins/compiler.js +428 -0
- package/dist/plugins/data.d.ts +12 -0
- package/dist/plugins/data.js +120 -0
- package/dist/result.d.ts +1 -1
- package/dist/result.js +1 -0
- package/dist/runtime.d.ts +22 -0
- package/dist/runtime.js +18 -0
- package/dist/schema.d.ts +590 -112
- package/dist/schema.js +60 -52
- package/dist/scope.js +14 -5
- package/dist/step-identity.d.ts +1 -1
- package/dist/step-identity.js +1 -1
- package/dist/themes.d.ts +7 -0
- package/dist/themes.js +5 -0
- package/dist/traits.d.ts +7 -0
- package/dist/traits.js +26 -0
- package/dist/validate.js +17 -4
- package/package.json +7 -4
- package/dist/diagram/elk.d.ts +0 -6
- package/dist/diagram/elk.js +0 -56
- package/dist/diagram/graph-layout.d.ts +0 -123
- package/dist/diagram/graph-layout.js +0 -620
- package/dist/diagram/index.d.ts +0 -41
- package/dist/diagram/index.js +0 -92
- package/dist/diagram/model.d.ts +0 -217
- package/dist/diagram/model.js +0 -189
- package/dist/diagram/sequence-layout.d.ts +0 -12
- package/dist/diagram/sequence-layout.js +0 -185
package/dist/schema.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ElementTraitsSchema } from "./traits.js";
|
|
1
2
|
/**
|
|
2
3
|
* Joplo IR(schemaVersion 2):由 TSX 源文件编译得到的中间表示,不是作者直接编辑的格式。
|
|
3
4
|
* 权威源是项目文件夹里的 TSX/TS 文件(ADR-0002);渲染器、播放器、校验器、构建只消费这里的 IR。
|
|
@@ -5,9 +6,16 @@
|
|
|
5
6
|
* 带 `source` 的对象记录其来源 `相对路径:行:列`,用于选中元素、诊断定位,让 Agent 只读写那一处。
|
|
6
7
|
*/
|
|
7
8
|
import { z } from 'zod';
|
|
8
|
-
import { COMPONENT_TYPES } from "./catalog.js";
|
|
9
|
+
import { COMPONENT_TYPES, PLUGIN_TYPE } from "./catalog.js";
|
|
9
10
|
/** 层级标签的预设图标(标签压窄时靠它认出是哪一层)。不写时:手机视口 mobile,其余 window。 */
|
|
10
11
|
export const LAYER_ICONS = ['window', 'browser', 'mobile', 'desktop', 'terminal', 'chat', 'agent', 'server', 'data', 'email', 'doc', 'flow'];
|
|
12
|
+
const DataPath = z.array(z.string().min(1));
|
|
13
|
+
const ScopeRule = z.lazy(() => z.strictObject({
|
|
14
|
+
path: DataPath, kind: z.enum(['map', 'items', 'values', 'reference']), domain: z.enum(['element', 'scene']).optional(),
|
|
15
|
+
prefix: z.string().optional(), references: z.array(DataPath).optional(), children: z.array(ScopeRule).optional(),
|
|
16
|
+
}));
|
|
17
|
+
const SlotSpec = z.strictObject({ text: z.array(DataPath).optional(), scope: z.union([z.literal('global'), z.array(ScopeRule)]).optional() });
|
|
18
|
+
const DataSpec = z.strictObject({ node: SlotSpec.optional(), step: SlotSpec.optional() });
|
|
11
19
|
export const SCHEMA_VERSION = 2;
|
|
12
20
|
/** 作者可写的 ID(对象键、元素 id)。 */
|
|
13
21
|
export const Id = z.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/, 'ID must start with a letter and contain only letters, digits, underscores, and hyphens');
|
|
@@ -29,40 +37,10 @@ export const Condition = z.lazy(() => z.union([
|
|
|
29
37
|
z.strictObject({ or: z.array(Condition) }),
|
|
30
38
|
z.strictObject({ not: Condition }),
|
|
31
39
|
]));
|
|
32
|
-
// ---------- 图表布局(D69):编译期算好,渲染器只读 ----------
|
|
33
|
-
const Num = z.number().finite();
|
|
34
|
-
const BoxS = z.strictObject({ x: Num, y: Num, w: Num, h: Num });
|
|
35
|
-
const PointS = z.strictObject({ x: Num, y: Num });
|
|
36
|
-
const Boxes = z.record(z.string(), BoxS);
|
|
37
|
-
export const DiagramLayoutSchema = z.union([
|
|
38
|
-
z.strictObject({
|
|
39
|
-
kind: z.literal('graph'),
|
|
40
|
-
engine: z.enum(['elk', 'grid']),
|
|
41
|
-
direction: z.enum(['right', 'down']).optional(),
|
|
42
|
-
width: Num,
|
|
43
|
-
height: Num,
|
|
44
|
-
nodes: Boxes,
|
|
45
|
-
groups: Boxes,
|
|
46
|
-
titles: Boxes,
|
|
47
|
-
edges: z.record(z.string(), z.strictObject({ points: z.array(PointS), label: BoxS.nullable() })),
|
|
48
|
-
starts: Boxes.optional(),
|
|
49
|
-
}),
|
|
50
|
-
z.strictObject({
|
|
51
|
-
kind: z.literal('sequence'),
|
|
52
|
-
width: Num,
|
|
53
|
-
height: Num,
|
|
54
|
-
actors: Boxes,
|
|
55
|
-
lifelines: z.record(z.string(), z.strictObject({ x: Num, y1: Num, y2: Num })),
|
|
56
|
-
messages: z.record(z.string(), z.strictObject({ points: z.array(PointS), label: BoxS.nullable(), n: z.number().int(), self: z.boolean() })),
|
|
57
|
-
groups: Boxes,
|
|
58
|
-
titles: Boxes,
|
|
59
|
-
blocks: Boxes,
|
|
60
|
-
blockTitles: Boxes,
|
|
61
|
-
}),
|
|
62
|
-
]);
|
|
63
40
|
export const SceneNode = z.lazy(() => z.strictObject({
|
|
64
41
|
id: z.string().min(1),
|
|
65
|
-
type: z.enum(COMPONENT_TYPES),
|
|
42
|
+
type: z.union([z.enum(COMPONENT_TYPES), z.string().regex(PLUGIN_TYPE)]),
|
|
43
|
+
traits: ElementTraitsSchema.optional(),
|
|
66
44
|
props: z.record(z.string(), Json).optional(),
|
|
67
45
|
children: z.array(SceneNode).optional(),
|
|
68
46
|
when: Condition.optional(),
|
|
@@ -72,7 +50,8 @@ export const SceneNode = z.lazy(() => z.strictObject({
|
|
|
72
50
|
note: z.string().optional(),
|
|
73
51
|
redact: z.union([z.boolean(), Condition]).optional(),
|
|
74
52
|
from: z.string().optional(),
|
|
75
|
-
|
|
53
|
+
ext: z.record(z.string(), Json).optional(),
|
|
54
|
+
framing: z.strictObject({ include: z.array(z.string()).optional(), kind: z.enum(['root', 'group', 'block', 'content', 'edge', 'row']).optional() }).optional(),
|
|
76
55
|
source: Source,
|
|
77
56
|
}));
|
|
78
57
|
/** 一个画面 = 某个方案上下文中的一个路径:布局 + 页面 + 堆叠进来的功能元素。 */
|
|
@@ -88,8 +67,18 @@ export const Scene = z.strictObject({
|
|
|
88
67
|
layer: z.string().optional(),
|
|
89
68
|
});
|
|
90
69
|
// ---------- 步骤与场景 ----------
|
|
70
|
+
const ActionPoint = z.strictObject({ x: z.number().finite(), y: z.number().finite() });
|
|
71
|
+
export const PluginAction = z.strictObject({
|
|
72
|
+
caption: z.string().min(1), durationMs: z.number().finite().positive().max(30000),
|
|
73
|
+
fields: z.record(z.string().regex(/^[A-Za-z][A-Za-z0-9_]*$/).refine(k => !['__proto__', 'prototype', 'constructor'].includes(k)), z.strictObject({ type: z.enum(['string', 'number', 'boolean']), min: z.number().finite().optional(), max: z.number().finite().optional(), tolerance: z.number().finite().nonnegative().optional(), text: z.boolean().optional() }).refine(f => (f.min === undefined || f.max === undefined || f.min <= f.max) && (f.type === 'number' || f.min === undefined && f.max === undefined && f.tolerance === undefined) && (!f.text || f.type === 'string'))),
|
|
74
|
+
targets: z.array(z.string().min(1)).optional(),
|
|
75
|
+
});
|
|
91
76
|
export const Action = z.discriminatedUnion('type', [
|
|
92
77
|
z.strictObject({ type: z.literal('click'), target: Id }),
|
|
78
|
+
z.strictObject({ type: z.literal('drag'), target: Id, to: z.union([Id, ActionPoint]) }),
|
|
79
|
+
z.strictObject({ type: z.literal('hover'), target: Id, ms: z.number().finite().nonnegative().max(30000) }),
|
|
80
|
+
z.strictObject({ type: z.literal('scroll'), target: Id, to: z.union([Id, ActionPoint.refine(p => p.x >= 0 && p.y >= 0)]) }),
|
|
81
|
+
z.strictObject({ type: z.literal('plugin'), name: z.string().regex(/^[a-z][a-z0-9-]*:[a-z][a-zA-Z0-9-]*$/), target: Id, data: z.record(z.string(), Json) }),
|
|
93
82
|
z.strictObject({ type: z.literal('type'), target: Id, value: z.string() }),
|
|
94
83
|
z.strictObject({ type: z.literal('select'), target: Id, value: z.string() }),
|
|
95
84
|
z.strictObject({ type: z.literal('toggle'), target: Id, value: z.boolean() }),
|
|
@@ -108,20 +97,6 @@ export const Effect = z.discriminatedUnion('type', [
|
|
|
108
97
|
/** 流式输出(D56):状态上等同 set;播放到这一步时绑定它的文字逐字出现。 */
|
|
109
98
|
z.strictObject({ type: z.literal('stream'), path: StatePath, value: z.string() }),
|
|
110
99
|
]);
|
|
111
|
-
/**
|
|
112
|
-
* 调用链(D48):这一步 trace 的一条路径。nodes 按路径顺序;edges 是路径上的连线,reverse = 沿连线的 to→from 方向走。
|
|
113
|
-
* mode:ok = 正常调用(本步 active,之后 ok);fail = 失败(连线与终点节点 error);skip = 没被调用(dim)。
|
|
114
|
-
*/
|
|
115
|
-
export const Trace = z.strictObject({
|
|
116
|
-
mode: z.enum(['ok', 'fail', 'skip']),
|
|
117
|
-
nodes: z.array(z.string().min(1)),
|
|
118
|
-
edges: z.array(z.strictObject({ id: z.string().min(1), reverse: z.boolean().default(false) })),
|
|
119
|
-
/** 路径经过的分组(节点所在的各级分组,D69):fail 时 errorGroups 是终点所在的分组。没有分组时省略(IR 与旧版相同)。 */
|
|
120
|
-
groups: z.array(z.string().min(1)).optional(),
|
|
121
|
-
errorGroups: z.array(z.string().min(1)).optional(),
|
|
122
|
-
/** 镜头目标:架构图 / 状态机是路径上的节点,时序图是消息(一行一行的)。旧 IR 没有,按 nodes 处理。 */
|
|
123
|
-
targets: z.array(z.string().min(1)).optional(),
|
|
124
|
-
});
|
|
125
100
|
/** 镜头(D43):这一步在某个层级里对准哪些元素;targets 为空 = 这一层的整体。 */
|
|
126
101
|
export const Shot = z.strictObject({ layer: z.string().min(1), targets: z.array(z.string().min(1)) });
|
|
127
102
|
export const Fork = z.strictObject({ label: z.string().min(1), scenarioId: Qid, at: z.number().int().nonnegative() });
|
|
@@ -135,16 +110,21 @@ export const Cue = z.strictObject({ kind: z.enum(CUE_KINDS), targets: z.array(z.
|
|
|
135
110
|
/** 标注气泡(D70):指向元素的一句话;side 不写时由渲染器选放得下的一侧。 */
|
|
136
111
|
export const CALLOUT_SIDES = ['top', 'right', 'bottom', 'left'];
|
|
137
112
|
export const Callout = z.strictObject({ target: z.string().min(1), text: z.string().min(1), side: z.enum(CALLOUT_SIDES).optional() });
|
|
113
|
+
export const MediaSnapshot = z.record(z.string(), z.strictObject({
|
|
114
|
+
plugin: z.string().min(1), resource: z.string().min(1), offsetMs: z.number().nonnegative(), startOffsetMs: z.number().nonnegative().optional(),
|
|
115
|
+
volume: z.number().min(0).max(1), loop: z.boolean(), fadeInMs: z.number().nonnegative(), stopAfterMs: z.number().nonnegative().optional(),
|
|
116
|
+
}));
|
|
138
117
|
export const Step = z.strictObject({
|
|
118
|
+
media: MediaSnapshot.optional(),
|
|
139
119
|
id: Qid,
|
|
140
|
-
/** Author identity, unique within a scenario. id remains the
|
|
120
|
+
/** Author identity, unique within a scenario. id remains the playback address. */
|
|
141
121
|
key: Id.optional(),
|
|
142
122
|
kind: z.enum(['user', 'system', 'card']),
|
|
143
123
|
action: Action,
|
|
144
124
|
caption: z.string().min(1),
|
|
145
125
|
/** Generated caption metadata; caption remains the English fallback for tools. */
|
|
146
126
|
captionAuto: z.strictObject({
|
|
147
|
-
kind: z.enum(['click', 'type', 'select', 'check', 'uncheck', 'switch_on', 'switch_off', 'back', 'press']),
|
|
127
|
+
kind: z.enum(['click', 'type', 'select', 'check', 'uncheck', 'switch_on', 'switch_off', 'back', 'press', 'drag', 'hover', 'scroll']),
|
|
148
128
|
label: z.string(),
|
|
149
129
|
value: z.string().optional(),
|
|
150
130
|
keys: z.string().optional(),
|
|
@@ -157,8 +137,11 @@ export const Step = z.strictObject({
|
|
|
157
137
|
directorLayer: z.string().nullable().default(null),
|
|
158
138
|
/** 较长的解说(来自 explain(),多个按换行连接):字幕区第二行显示(说明下方、小一号);发布站保留。 */
|
|
159
139
|
explain: z.string().min(1).optional(),
|
|
160
|
-
/**
|
|
161
|
-
|
|
140
|
+
/** 插件效果降级后的逐步快照。 */
|
|
141
|
+
ext: z.record(z.string(), Json).optional(),
|
|
142
|
+
/** 插件效果贡献的显式焦点与引用(scope 校验)。 */
|
|
143
|
+
focusTargets: z.array(z.string()).optional(),
|
|
144
|
+
references: z.array(z.string()).optional(),
|
|
162
145
|
/** 分叉是演示信息,发布保留;at 在编译时比较动作与业务效果的公共前缀。 */
|
|
163
146
|
forks: z.array(Fork).default([]),
|
|
164
147
|
/** 本步标注,不累积,不参与状态转换。 */
|
|
@@ -176,6 +159,14 @@ export const Step = z.strictObject({
|
|
|
176
159
|
source: Source,
|
|
177
160
|
});
|
|
178
161
|
export const Scenario = z.strictObject({
|
|
162
|
+
/** Optional chapters remain selectable but do not join sequential autoplay. */
|
|
163
|
+
autoplay: z.boolean().optional(),
|
|
164
|
+
/** Where a confirmed cross-scenario action enters; autoplay is unaffected. */
|
|
165
|
+
actionEntry: z.enum(['before', 'after']).optional(),
|
|
166
|
+
/** flow({ from }) 接力的上一个场景(D92):连续播放时一镜到底接上,不倒计时、不重置画面与配乐。 */
|
|
167
|
+
from: Qid.optional(),
|
|
168
|
+
media: MediaSnapshot.optional(),
|
|
169
|
+
ext: z.record(z.string(), Json).optional(),
|
|
179
170
|
id: Qid,
|
|
180
171
|
optionId: Qid,
|
|
181
172
|
name: z.string().min(1),
|
|
@@ -236,7 +227,9 @@ export const Coverage = z.strictObject({
|
|
|
236
227
|
/** derived = 编译器根据场景推导;declared = 作者在源文件中声明。 */
|
|
237
228
|
basis: z.enum(['derived', 'declared']).default('declared'),
|
|
238
229
|
});
|
|
230
|
+
export const FreeReaction = z.strictObject({ action: Action, effects: z.array(Effect).default([]), source: Source });
|
|
239
231
|
export const Option = z.strictObject({
|
|
232
|
+
free: z.record(Id, FreeReaction).optional(),
|
|
240
233
|
id: Qid,
|
|
241
234
|
featureId: Id,
|
|
242
235
|
/** 文件名,例如 `a-modal`。 */
|
|
@@ -310,6 +303,8 @@ export const VoiceIndex = z.strictObject({
|
|
|
310
303
|
/** 内容语言(D84)→ 这种语言的旁白与角色指纹;没有的语言用上面的默认声音。 */
|
|
311
304
|
locales: z.record(z.string(), z.strictObject({ narrator: z.string().min(1).nullable(), roles: z.record(z.string(), z.string().min(1)).default({}), overrides: z.record(z.string(), z.string().min(1)).optional() })).optional(),
|
|
312
305
|
});
|
|
306
|
+
/** Only calibrated numeric playback data may cross the author/public boundary. */
|
|
307
|
+
export const AudioRegionSchema = z.strictObject({ sourceSampleRate: z.number().positive(), cycleFrames: z.number().int().positive(), contentStartFrame: z.number().int().nonnegative(), contentFrames: z.number().int().positive(), decodedFrames: z.number().int().positive(), encoderDelayFrames: z.number().int().nonnegative(), paddingFrames: z.number().int().nonnegative(), channels: z.number().int().min(1).max(2) }).refine(v => v.contentStartFrame + v.contentFrames <= v.decodedFrames && v.cycleFrames <= v.contentFrames, 'Audio region exceeds decoded samples');
|
|
313
308
|
export const Project = z.strictObject({
|
|
314
309
|
schemaVersion: z.literal(SCHEMA_VERSION),
|
|
315
310
|
name: z.string().min(1),
|
|
@@ -320,8 +315,21 @@ export const Project = z.strictObject({
|
|
|
320
315
|
autoFocus: z.boolean().optional(),
|
|
321
316
|
voiceConfig: VoiceConfig.optional(),
|
|
322
317
|
voiceIndex: VoiceIndex.optional(),
|
|
318
|
+
mediaAssets: z.record(z.string(), z.string()).optional(),
|
|
319
|
+
mediaInfo: z.record(z.string(), AudioRegionSchema).optional(),
|
|
323
320
|
/** 作者内容多语言(D84):只有 config 写了 locales 才有。messages 只含非默认语言、这份 IR 用得到的译文;stale 只在 dev IR。 */
|
|
324
321
|
i18n: ContentI18nSchema.optional(),
|
|
322
|
+
/** 启用的插件(D86):插件 id → 名称、版本与组件声明(可操作、父组件)。运行时代码不在 IR 里,由看板 / 发布站另外载入。 */
|
|
323
|
+
plugins: z.record(z.string(), z.strictObject({
|
|
324
|
+
actions: z.record(z.string(), PluginAction).optional(),
|
|
325
|
+
themes: z.record(z.string(), z.string()).optional(),
|
|
326
|
+
properties: z.record(z.string(), z.strictObject({ type: z.enum(['string', 'number', 'boolean']), attribute: z.string().regex(/^data-jp-[a-z0-9-]+$/).optional(), min: z.number().optional(), max: z.number().optional(), nonempty: z.boolean().optional(), values: z.array(z.string()).optional() })).optional(),
|
|
327
|
+
data: DataSpec.optional(),
|
|
328
|
+
id: z.string().min(1),
|
|
329
|
+
title: z.string(),
|
|
330
|
+
version: z.string().optional(),
|
|
331
|
+
components: z.record(z.string(), z.strictObject({ interactive: z.boolean().optional(), parent: z.string().optional(), needsId: z.boolean().optional(), selfEvident: z.boolean().optional(), traits: ElementTraitsSchema.optional() })),
|
|
332
|
+
})).optional(),
|
|
325
333
|
/** 作者主题(D51):主题名 → CSS 原文(themes/<name>.css);渲染时自动限定在舞台范围内。发布站同样打包。 */
|
|
326
334
|
themes: z.record(z.string(), z.string()).default({}),
|
|
327
335
|
/** dev = 含全部方案(本地看板);publish = 只含选定方案,且去掉创作侧信息(D33);review = 评审版:全部方案,同样去掉创作侧信息(D63)。 */
|
package/dist/scope.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { pruneMediaAssets } from "./media.js";
|
|
2
|
+
import { scopePluginData } from "./plugin-data.js";
|
|
1
3
|
/**
|
|
2
4
|
* 按场景保密分享(D75):把编译好的 IR 裁剪到若干场景。
|
|
3
5
|
*
|
|
@@ -75,6 +77,8 @@ export function stepRefs(st) {
|
|
|
75
77
|
const out = [];
|
|
76
78
|
if ('target' in st.action)
|
|
77
79
|
out.push(st.action.target);
|
|
80
|
+
if ((st.action.type === 'drag' || st.action.type === 'scroll') && typeof st.action.to === 'string')
|
|
81
|
+
out.push(st.action.to);
|
|
78
82
|
for (const s of st.shots)
|
|
79
83
|
out.push(...s.targets);
|
|
80
84
|
for (const m of st.marks)
|
|
@@ -83,8 +87,7 @@ export function stepRefs(st) {
|
|
|
83
87
|
out.push(...c.targets);
|
|
84
88
|
for (const c of st.callouts ?? [])
|
|
85
89
|
out.push(c.target);
|
|
86
|
-
|
|
87
|
-
out.push(...t.nodes, ...t.edges.map((e) => e.id), ...(t.groups ?? []), ...(t.errorGroups ?? []), ...(t.targets ?? []));
|
|
90
|
+
out.push(...st.references ?? []);
|
|
88
91
|
return out;
|
|
89
92
|
}
|
|
90
93
|
function idsIn(n, out = []) {
|
|
@@ -190,7 +193,8 @@ export function scopeProject(project, scenarioIds, mode = project.mode === 'revi
|
|
|
190
193
|
if (!S.has(sid))
|
|
191
194
|
continue;
|
|
192
195
|
const s = project.scenarios[sid];
|
|
193
|
-
|
|
196
|
+
const { from, ...rest } = s;
|
|
197
|
+
scenarios[sid] = { ...rest, ...(from && S.has(from) ? { from } : {}), steps: s.steps.map((st) => (st.forks.some((f) => !S.has(f.scenarioId)) ? { ...st, forks: st.forks.filter((f) => S.has(f.scenarioId)) } : st)) };
|
|
194
198
|
}
|
|
195
199
|
const options = {};
|
|
196
200
|
for (const [id, o] of Object.entries(project.options)) {
|
|
@@ -199,7 +203,12 @@ export function scopeProject(project, scenarioIds, mode = project.mode === 'revi
|
|
|
199
203
|
const coverage = Object.fromEntries(Object.entries(o.coverage)
|
|
200
204
|
.filter(([cid]) => F.has(project.cases[cid]?.featureId ?? cid.split('.')[0] ?? ''))
|
|
201
205
|
.map(([cid, c]) => [cid, { ...c, scenarioIds: c.scenarioIds.filter((x) => S.has(x)) }]));
|
|
202
|
-
|
|
206
|
+
const retained = new Set(Object.values(scenes).filter(s => s.optionId === id || s.optionId === null).flatMap(s => idsIn(s.root)));
|
|
207
|
+
const free = o.free ? Object.fromEntries(Object.entries(o.free).filter(([, reaction]) => {
|
|
208
|
+
const a = reaction.action;
|
|
209
|
+
return 'target' in a && retained.has(a.target) && (!('to' in a) || typeof a.to !== 'string' || retained.has(a.to));
|
|
210
|
+
})) : undefined;
|
|
211
|
+
options[id] = { ...o, coverage, ...(free ? { free } : {}) };
|
|
203
212
|
}
|
|
204
213
|
const features = {};
|
|
205
214
|
for (const f of orderedFeatures(project)) {
|
|
@@ -237,7 +246,7 @@ export function scopeProject(project, scenarioIds, mode = project.mode === 'revi
|
|
|
237
246
|
};
|
|
238
247
|
const ids = Object.keys(scenarios);
|
|
239
248
|
// 译文只留范围内用得到的(D84):别的功能的文字不随范围分享出去
|
|
240
|
-
return { project: pruneMessages(out), info: { key: scopeKey(ids, mode), scenarios: ids, features: Object.keys(features), borrowed: merged } };
|
|
249
|
+
return { project: pruneMediaAssets(pruneMessages(scopePluginData(out))), info: { key: scopeKey(ids, mode), scenarios: ids, features: Object.keys(features), borrowed: merged } };
|
|
241
250
|
}
|
|
242
251
|
/** 一条借用的说明(英文,CLI 与看板共用)。 */
|
|
243
252
|
export function borrowedLine(b) {
|
package/dist/step-identity.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Stable author identities are separate from public playback IR
|
|
1
|
+
/** Stable author identities are separate from public playback IR to keep author identity metadata separate from runtime state. */
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { Project } from './schema.js';
|
|
4
4
|
export declare const StepIdentity: z.ZodObject<{
|
package/dist/step-identity.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Stable author identities are separate from public playback IR
|
|
1
|
+
/** Stable author identities are separate from public playback IR to keep author identity metadata separate from runtime state. */
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { Id, Project, Qid, SCHEMA_VERSION } from "./schema.js";
|
|
4
4
|
import { JoploError } from "./result.js";
|
package/dist/themes.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Combine plugin-owned CSS with author CSS; author themes keep their existing IR semantics. */
|
|
2
|
+
export declare function projectThemes(project: {
|
|
3
|
+
themes?: Record<string, string>;
|
|
4
|
+
plugins?: Record<string, {
|
|
5
|
+
themes?: Record<string, string>;
|
|
6
|
+
}>;
|
|
7
|
+
} | null | undefined): Record<string, string>;
|
package/dist/themes.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Combine plugin-owned CSS with author CSS; author themes keep their existing IR semantics. */
|
|
2
|
+
export function projectThemes(project) {
|
|
3
|
+
const pluginThemes = Object.fromEntries(Object.entries(project?.plugins ?? {}).flatMap(([id, plugin]) => Object.entries(plugin.themes ?? {}).map(([name, css]) => [`${id}:${name}`, css])));
|
|
4
|
+
return { ...pluginThemes, ...project?.themes };
|
|
5
|
+
}
|
package/dist/traits.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ElementTraits } from '@joplo-app/kit/plugin';
|
|
3
|
+
export declare const ElementTraitsSchema: z.ZodType<ElementTraits>;
|
|
4
|
+
export declare const InheritSchema: z.ZodArray<z.ZodObject<{
|
|
5
|
+
target: z.ZodString;
|
|
6
|
+
props: z.ZodArray<z.ZodString>;
|
|
7
|
+
}, z.core.$strict>>;
|
package/dist/traits.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const key = z.string().min(1).refine(s => !['__proto__', 'prototype', 'constructor'].includes(s));
|
|
3
|
+
const keys = z.array(key).min(1);
|
|
4
|
+
export const ElementTraitsSchema = z.strictObject({
|
|
5
|
+
native: z.strictObject({ action: z.enum(['type', 'toggle', 'select']), prop: key, deselect: z.boolean().optional() }).optional(),
|
|
6
|
+
draggable: z.boolean().optional(),
|
|
7
|
+
hover: z.boolean().optional(),
|
|
8
|
+
selectionGate: z.strictObject({ owner: key, item: key.optional(), value: key, fallbackFirst: z.boolean().optional() }).optional(),
|
|
9
|
+
disabledPresentation: z.boolean().optional(),
|
|
10
|
+
frame: z.boolean().optional(),
|
|
11
|
+
input: z.enum(['single', 'multiple']).optional(),
|
|
12
|
+
gate: keys.optional(),
|
|
13
|
+
choices: z.union([
|
|
14
|
+
z.strictObject({ prop: key }),
|
|
15
|
+
z.strictObject({ descendants: keys, value: key.optional(), label: key.optional(), labelChild: key.optional() }),
|
|
16
|
+
z.strictObject({ range: key }),
|
|
17
|
+
]).optional(),
|
|
18
|
+
toggleCaption: z.literal('check').optional(),
|
|
19
|
+
selfEvident: z.boolean().optional(),
|
|
20
|
+
layout: z.record(key, z.strictObject({ size: key, defaultSize: z.number().finite().nonnegative(), breakpoint: z.boolean().optional() })).optional(),
|
|
21
|
+
region: key.optional(),
|
|
22
|
+
childWidth: z.strictObject({ value: z.number().finite().positive(), when: z.strictObject({ prop: key, value: z.union([z.string(), z.number().finite(), z.boolean()]), width: z.number().finite().positive() }).optional() }).optional(),
|
|
23
|
+
text: z.array(key).optional(),
|
|
24
|
+
textPaths: z.array(keys).optional(),
|
|
25
|
+
});
|
|
26
|
+
export const InheritSchema = z.array(z.strictObject({ target: key, props: keys }));
|
package/dist/validate.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { pluginSpec } from "./catalog.js";
|
|
1
2
|
import { orderedFeatures } from "./features.js";
|
|
2
3
|
import { Project } from "./schema.js";
|
|
3
|
-
import { CAPTION_MAX, CARD_POINTS_MAX, DESCRIPTION_MAX, EXPLAIN_MAX, SAY_MAX,
|
|
4
|
+
import { CAPTION_MAX, CARD_POINTS_MAX, DESCRIPTION_MAX, EXPLAIN_MAX, SAY_MAX, isInteractiveType, SCENARIO_MS_MAX, captionLength } from "./catalog.js";
|
|
4
5
|
import { scenarioEstimateMs } from "./outline.js";
|
|
5
6
|
import { walkNodes, findNode, replay } from "./player.js";
|
|
6
7
|
import { JoploError } from "./result.js";
|
|
@@ -135,6 +136,16 @@ export function validate(project, opts = { mode: 'all' }) {
|
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
}
|
|
139
|
+
for (const option of Object.values(p.options))
|
|
140
|
+
for (const reaction of Object.values(option.free ?? {})) {
|
|
141
|
+
if (!('target' in reaction.action))
|
|
142
|
+
continue;
|
|
143
|
+
for (const scene of Object.values(p.scenes).filter(s => s.optionId === option.id || s.optionId === null)) {
|
|
144
|
+
const hit = findNode(scene, reaction.action.target)?.node;
|
|
145
|
+
if (hit && (!hit.from || hit.from === option.id))
|
|
146
|
+
bound.add(identity(hit));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
138
149
|
for (const s of Object.values(p.scenes).filter(s => included(s.optionId))) {
|
|
139
150
|
const value = { id: s.id, optionId: s.optionId ?? undefined, source: s.root.source ?? (s.optionId ? p.options[s.optionId]?.source : undefined) };
|
|
140
151
|
ref(p.scenes[s.id] === s, `Stage key does not match ID: ${s.id}`, value, 'scene');
|
|
@@ -143,14 +154,16 @@ export function validate(project, opts = { mode: 'all' }) {
|
|
|
143
154
|
ref(p.routes[s.route], `Stage route does not exist: ${s.route}`, value, 'scene');
|
|
144
155
|
const ids = new Set();
|
|
145
156
|
walkNodes(s.root, n => {
|
|
157
|
+
if (pluginSpec(p.plugins, n.type)?.needsId && n.id.startsWith('_'))
|
|
158
|
+
emit('error', 'MISSING_ID', `<${n.type}> requires an author id; recompile after adding id`, n.source, { kind: 'element', id: n.id });
|
|
146
159
|
const r = { kind: 'element', id: n.id, optionId: n.from ?? s.optionId ?? undefined };
|
|
147
160
|
if (ids.has(n.id))
|
|
148
161
|
emit('error', 'DUPLICATE_ELEMENT', `Duplicate element ID in stage: ${n.id}`, n.source, r, 'reference');
|
|
149
162
|
ids.add(n.id);
|
|
150
|
-
//
|
|
151
|
-
if (n.disabled !== undefined && n.disabled !== false && !n.disabledReason?.trim() && n.
|
|
163
|
+
// Plugins may declare disabled as presentation-only, which requires no unavailability reason.
|
|
164
|
+
if (n.disabled !== undefined && n.disabled !== false && !n.disabledReason?.trim() && !n.traits?.disabledPresentation)
|
|
152
165
|
emit('warning', 'DISABLED_WITHOUT_REASON', `Disabled element has no reason: ${n.id}. Add disabledReason="…" (for example disabledReason="Only admins can invite"), or bind it to state like disabled: disabledReason={$.ui.sendHint}`, n.source, r);
|
|
153
|
-
if (
|
|
166
|
+
if (isInteractiveType(n.type, project.plugins) && !bound.has(identity(n)) && !(n.disabled === true && n.disabledReason?.trim()) && !n.unmodeled)
|
|
154
167
|
emit('warning', 'UNBOUND_INTERACTIVE', `Interactive element has no demo step: ${n.id}; bind a step, disable with a reason, or mark unmodeled`, n.source, r);
|
|
155
168
|
});
|
|
156
169
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joplo-app/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Joplo 编译器、校验器与播放器(IR v2)",
|
|
5
5
|
"license": "PolyForm-Shield-1.0.0",
|
|
6
6
|
"type": "module",
|
|
@@ -13,14 +13,17 @@
|
|
|
13
13
|
"types": "./dist/node.d.ts",
|
|
14
14
|
"default": "./dist/node.js"
|
|
15
15
|
},
|
|
16
|
-
"./package.json": "./package.json"
|
|
16
|
+
"./package.json": "./package.json",
|
|
17
|
+
"./runtime": {
|
|
18
|
+
"types": "./dist/runtime.d.ts",
|
|
19
|
+
"default": "./dist/runtime.js"
|
|
20
|
+
}
|
|
17
21
|
},
|
|
18
22
|
"files": [
|
|
19
23
|
"dist"
|
|
20
24
|
],
|
|
21
25
|
"dependencies": {
|
|
22
|
-
"@joplo-app/kit": "0.
|
|
23
|
-
"elkjs": "0.12.1",
|
|
26
|
+
"@joplo-app/kit": "0.3.0",
|
|
24
27
|
"zod": "4.6.7"
|
|
25
28
|
},
|
|
26
29
|
"engines": {
|
package/dist/diagram/elk.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type ElkRun, type LayoutGoal } from './graph-layout.js';
|
|
2
|
-
import { type GraphLayout, type GraphStructure } from './model.js';
|
|
3
|
-
/** 同步运行一次 ELK 布局;ELK 报错时抛出 Error。 */
|
|
4
|
-
export declare const runElk: ElkRun;
|
|
5
|
-
/** 编译期的图表布局引擎:传给 compile(src, mode, { layout: elkLayout })。goal = 目标外框比例(舞台比例)。 */
|
|
6
|
-
export declare function elkLayout(s: GraphStructure, goal?: LayoutGoal): GraphLayout;
|
package/dist/diagram/elk.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 仅限 Node:同步运行 elkjs(Eclipse Layout Kernel 的 JS 版,EPL-2.0),给编译期的图表布局用(D69)。
|
|
3
|
-
*
|
|
4
|
-
* elkjs 的公开 API 是异步的(Web Worker 或 setTimeout 模拟的 FakeWorker),但它的 Dispatcher 本身是同步的:
|
|
5
|
-
* 直接调用 FakeWorker.dispatcher.saveDispatch,回调在同一个调用栈里返回结果。这样 compile() 保持同步,
|
|
6
|
-
* check、dev、build 的调用方式都不变。elkjs 固定版本(package.json 精确版本),这个内部接口由测试守住。
|
|
7
|
-
*
|
|
8
|
-
* elkjs 只在这里加载:浏览器端(看板、发布站)不打包它,发布站只读 IR 里写好的坐标。
|
|
9
|
-
*/
|
|
10
|
-
import { createRequire } from 'node:module';
|
|
11
|
-
import { DEFAULT_ASPECT, layoutGraph } from "./graph-layout.js";
|
|
12
|
-
import { structureKey } from "./model.js";
|
|
13
|
-
let worker = null;
|
|
14
|
-
function elkWorker() {
|
|
15
|
-
if (worker)
|
|
16
|
-
return worker;
|
|
17
|
-
const require = createRequire(import.meta.url);
|
|
18
|
-
const mod = require('elkjs/lib/elk-worker.min.js');
|
|
19
|
-
const w = new mod.Worker();
|
|
20
|
-
w.onmessage = () => { };
|
|
21
|
-
w.dispatcher.saveDispatch({ data: { id: 0, cmd: 'register', algorithms: ['layered'] } });
|
|
22
|
-
worker = w;
|
|
23
|
-
return w;
|
|
24
|
-
}
|
|
25
|
-
/** 同步运行一次 ELK 布局;ELK 报错时抛出 Error。 */
|
|
26
|
-
export const runElk = (graph) => {
|
|
27
|
-
const w = elkWorker();
|
|
28
|
-
let out = null;
|
|
29
|
-
w.onmessage = (e) => {
|
|
30
|
-
out = e.data;
|
|
31
|
-
};
|
|
32
|
-
w.dispatcher.saveDispatch({ data: { id: 1, cmd: 'layout', graph, layoutOptions: {}, options: {} } });
|
|
33
|
-
const res = out;
|
|
34
|
-
if (!res)
|
|
35
|
-
throw new Error('ELK did not return a layout');
|
|
36
|
-
if (res.error) {
|
|
37
|
-
const e = res.error;
|
|
38
|
-
throw new Error(String(e.message ?? e.g ?? e).split('\n')[0].slice(0, 300));
|
|
39
|
-
}
|
|
40
|
-
return res.data;
|
|
41
|
-
};
|
|
42
|
-
/** 按结构缓存(dev 每次保存都重新编译,结构没变的图不再跑 ELK)。 */
|
|
43
|
-
const cache = new Map();
|
|
44
|
-
const CACHE_MAX = 300;
|
|
45
|
-
/** 编译期的图表布局引擎:传给 compile(src, mode, { layout: elkLayout })。goal = 目标外框比例(舞台比例)。 */
|
|
46
|
-
export function elkLayout(s, goal = { aspect: DEFAULT_ASPECT }) {
|
|
47
|
-
const key = `${goal.aspect.toFixed(3)}|${goal.width ?? ''}|${goal.height ?? ''}|${structureKey(s)}`;
|
|
48
|
-
const hit = cache.get(key);
|
|
49
|
-
if (hit)
|
|
50
|
-
return structuredClone(hit);
|
|
51
|
-
const l = layoutGraph(structuredClone(s), runElk, goal);
|
|
52
|
-
cache.set(key, l);
|
|
53
|
-
if (cache.size > CACHE_MAX)
|
|
54
|
-
cache.delete(cache.keys().next().value);
|
|
55
|
-
return structuredClone(l);
|
|
56
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 架构图 / 状态机的布局(D69):ELK layered + 层级处理(hierarchyHandling = INCLUDE_CHILDREN),正交走线。
|
|
3
|
-
*
|
|
4
|
-
* 可读性修复(D69 补充,用户看了 v2 的效果:“几乎看不到谁调用了谁”):
|
|
5
|
-
* - 比例适应舞台:同时试几种候选(方向 right / down × 是否压缩层次),取外框比例最接近目标(舞台)比例的一种;
|
|
6
|
-
* 作者写了 direction 时只在这个方向里选。ELK 在层级图里不支持“分组各自的方向”和图换行,所以靠这两个杠杆:
|
|
7
|
-
* - 方向;
|
|
8
|
-
* - 压缩层次:节点有多个上游时,把它推到最深处的那条次要连线(优先 async)在分层时反向,图变浅、变宽。
|
|
9
|
-
* - 连线可读:端口沿节点边均匀分散,平行连线之间至少 16px;上→下时标签不占层,布局后贴在自己的线段中部(带底色)。
|
|
10
|
-
*
|
|
11
|
-
* 本文件是纯函数,ELK 由调用方注入(Node 入口 diagram/elk.ts 同步运行 elkjs)。流程:
|
|
12
|
-
* 1. 结构 → ELK 图:节点尺寸来自 model.ts 的估算;分组是复合节点(顶部留出标题条);连线标签带尺寸,ELK 为它们留位置。
|
|
13
|
-
* 2. 回边(让图成环的连线,如“工具调用”回到 Biz Server、“回复”回到客户端)自己按源码顺序做 DFS 找出,
|
|
14
|
-
* 交给 ELK 前先反向,布局后再把折线反回来:方向由作者的书写顺序决定,结果稳定、可预期。
|
|
15
|
-
* 另外“指回上游所在分组”的连线也按回边处理,避免把一个分组拉成横跨整张图的长条。
|
|
16
|
-
* 3. 布局结果平移到 (M, M)、坐标取 0.5px,分组标题沿顶部标题条找一个没有连线穿过的位置。
|
|
17
|
-
*
|
|
18
|
-
* 同一结构总是得到同一结果:ELK 的随机种子固定,输入按源码顺序,算法本身是确定的(测试覆盖)。
|
|
19
|
-
*/
|
|
20
|
-
import { type Box, type GEdge, type GraphLayout, type GraphStructure, type Point } from './model.js';
|
|
21
|
-
/** 一种布局候选:方向、是否压缩层次、标签是否作为占位参与 ELK 分层。 */
|
|
22
|
-
export type LayoutVariant = {
|
|
23
|
-
direction: 'right' | 'down';
|
|
24
|
-
compact: boolean;
|
|
25
|
-
labelsInLayout: boolean;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* 布局目标(由 attachLayouts 按页面设备与 h / aspect 算出):外框的宽高比;知道放图的区域大小时同时给 width / height,
|
|
29
|
-
* 候选按“放进这个区域后的缩放比例”比较(缩放越大,舞台上的字越大)。
|
|
30
|
-
*/
|
|
31
|
-
export type LayoutGoal = {
|
|
32
|
-
aspect: number;
|
|
33
|
-
width?: number;
|
|
34
|
-
height?: number;
|
|
35
|
-
};
|
|
36
|
-
/** 电脑舞台的目标比例:1280 × 800 的舞台留出四周边距后约 1232 × 756。 */
|
|
37
|
-
export declare const DEFAULT_ASPECT: number;
|
|
38
|
-
/** ELK JSON 图(只用到的字段)。 */
|
|
39
|
-
export type ElkNode = {
|
|
40
|
-
id: string;
|
|
41
|
-
width?: number;
|
|
42
|
-
height?: number;
|
|
43
|
-
x?: number;
|
|
44
|
-
y?: number;
|
|
45
|
-
layoutOptions?: Record<string, string>;
|
|
46
|
-
children?: ElkNode[];
|
|
47
|
-
edges?: ElkEdge[];
|
|
48
|
-
labels?: {
|
|
49
|
-
text?: string;
|
|
50
|
-
width: number;
|
|
51
|
-
height: number;
|
|
52
|
-
x?: number;
|
|
53
|
-
y?: number;
|
|
54
|
-
}[];
|
|
55
|
-
};
|
|
56
|
-
export type ElkEdge = {
|
|
57
|
-
id: string;
|
|
58
|
-
sources: string[];
|
|
59
|
-
targets: string[];
|
|
60
|
-
labels?: {
|
|
61
|
-
text?: string;
|
|
62
|
-
width: number;
|
|
63
|
-
height: number;
|
|
64
|
-
x?: number;
|
|
65
|
-
y?: number;
|
|
66
|
-
layoutOptions?: Record<string, string>;
|
|
67
|
-
}[];
|
|
68
|
-
sections?: {
|
|
69
|
-
startPoint: Point;
|
|
70
|
-
endPoint: Point;
|
|
71
|
-
bendPoints?: Point[];
|
|
72
|
-
}[];
|
|
73
|
-
};
|
|
74
|
-
/** 布局引擎:输入 ELK JSON,返回带坐标的同一张图(同步)。 */
|
|
75
|
-
export type ElkRun = (graph: ElkNode) => ElkNode;
|
|
76
|
-
/**
|
|
77
|
-
* 根图的 ELK 选项。间距宁可宽松也不挤:平行连线之间 ≥ 16px、端口沿节点边均匀分散,
|
|
78
|
-
* 整图缩小到舞台上时仍能分清每一条线(D69 补充)。
|
|
79
|
-
*/
|
|
80
|
-
export declare function rootOptions(direction: 'right' | 'down'): Record<string, string>;
|
|
81
|
-
/**
|
|
82
|
-
* 回边:按源码顺序做 DFS(先从没有入边的节点出发,pin="start" 的最先、pin="end" 的最后),指向栈上节点的连线是回边;
|
|
83
|
-
* 再加上“指回上游所在分组”的连线(u → v,v 所在、不包含 u 的最外层分组里有别的成员能走到 u)。
|
|
84
|
-
* 连到分组的连线不参与(交给 ELK 自己处理)。
|
|
85
|
-
*/
|
|
86
|
-
export declare function feedbackEdges(s: GraphStructure): Set<string>;
|
|
87
|
-
/**
|
|
88
|
-
* 压缩层次(D69 补充):ELK 的层级布局按容器逐层排——在每个容器(整张图或一个分组)里,子节点和子分组各是一个单元,
|
|
89
|
-
* 跨单元的连线“提升”成单元之间的连线。某个单元有多个上游时,它的层次由最深的上游决定;让那条连线“不参与分层”
|
|
90
|
-
* (相当于 Graphviz 的 constraint=false,做法见 toElk),单元就能和较浅的上游并排,整张图变浅、变宽
|
|
91
|
-
* (例如“计费”与“大脑”并排在“控制面”下面)。只放开“还有别的入边”的连线(不让单元变成孤立的起点),
|
|
92
|
-
* 优先 async 连线、其次写在后面的;每次只在这一层真的变浅时接受。返回这些连线的 id。
|
|
93
|
-
*/
|
|
94
|
-
export declare function compactReversals(s: GraphStructure, base: Set<string>): Set<string>;
|
|
95
|
-
/** 结构 → ELK JSON。连线放在根上(edgeCoords = ROOT,ELK 自己找最近的公共祖先)。 */
|
|
96
|
-
export declare function toElk(s: GraphStructure, variant?: LayoutVariant): {
|
|
97
|
-
graph: ElkNode;
|
|
98
|
-
reversed: Set<string>;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* 布局:结构 → 坐标(ELK),再整理成 IR 用的 GraphLayout。
|
|
102
|
-
* 作者写了方向时只在这个方向里选;没写(auto)时 right、down 都试。每个方向再试“压缩层次”与否,
|
|
103
|
-
* 取“放进舞台后缩放比例最大”(字最大)的一种,比例偏差、交叉、压缩略扣分。结果确定。
|
|
104
|
-
*/
|
|
105
|
-
export declare function layoutGraph(s: GraphStructure, run: ElkRun, goal?: LayoutGoal): GraphLayout;
|
|
106
|
-
/** 两条连线(正交折线)之间的交叉数。 */
|
|
107
|
-
export declare function crossings(l: Pick<GraphLayout, 'edges'>): number;
|
|
108
|
-
/** 一种候选的完整布局。 */
|
|
109
|
-
export declare function layoutVariant(s: GraphStructure, run: ElkRun, variant: LayoutVariant): GraphLayout;
|
|
110
|
-
/**
|
|
111
|
-
* 标签贴在自己的线上:从折线中点出发沿线向两侧找位置(先压在线上,再贴在线的两侧),标签框不与节点、分组标题条、
|
|
112
|
-
* 已放好的标签重叠,尽量不压别的连线;都不行时取代价最小的位置。按源码顺序放,结果确定。
|
|
113
|
-
*/
|
|
114
|
-
export declare function placeLabels(list: GEdge[], routes: GraphLayout['edges'], obstacles: Box[]): Map<string, Box>;
|
|
115
|
-
/** 沿折线每 4px 取一个点。 */
|
|
116
|
-
export declare function sampleRoute(points: Point[], step?: number): Point[];
|
|
117
|
-
/** 分组标题:在分组顶部标题条里,从左往右找一个没有连线穿过的位置;都有时取穿过最少的。 */
|
|
118
|
-
export declare function placeTitles(s: GraphStructure, groups: Record<string, Box>, edges: GraphLayout['edges']): Record<string, Box>;
|
|
119
|
-
/**
|
|
120
|
-
* 没有布局引擎时的退化排列(测试、或绕过 server 直接调用 compile 的旧代码):按源码顺序排成网格,分组包住成员。
|
|
121
|
-
* 只保证不重叠、结果确定;正式产物(dev / build / check)都用 ELK。
|
|
122
|
-
*/
|
|
123
|
-
export declare function gridLayout(s: GraphStructure): GraphLayout;
|