@joplo-app/core 0.2.17 → 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.
Files changed (64) hide show
  1. package/dist/actions.d.ts +6 -0
  2. package/dist/actions.js +34 -0
  3. package/dist/agent-skill.d.ts +10 -13
  4. package/dist/agent-skill.js +52 -31
  5. package/dist/auto-caption.d.ts +22 -0
  6. package/dist/auto-caption.js +166 -0
  7. package/dist/catalog.d.ts +38 -41
  8. package/dist/catalog.js +26 -317
  9. package/dist/compile.d.ts +2 -8
  10. package/dist/compile.js +302 -353
  11. package/dist/content-i18n.js +27 -16
  12. package/dist/feature-diff.d.ts +3 -3
  13. package/dist/feature-diff.js +28 -6
  14. package/dist/focus.d.ts +3 -1
  15. package/dist/focus.js +16 -34
  16. package/dist/guide.d.ts +10 -12
  17. package/dist/guide.js +419 -519
  18. package/dist/index.d.ts +4 -1
  19. package/dist/index.js +4 -1
  20. package/dist/media.d.ts +10 -0
  21. package/dist/media.js +43 -0
  22. package/dist/node.d.ts +1 -2
  23. package/dist/node.js +1 -2
  24. package/dist/outline.d.ts +1 -1
  25. package/dist/outline.js +3 -3
  26. package/dist/pace.d.ts +9 -1
  27. package/dist/pace.js +23 -3
  28. package/dist/player.d.ts +8 -41
  29. package/dist/player.js +85 -148
  30. package/dist/playground.d.ts +38 -0
  31. package/dist/playground.js +111 -0
  32. package/dist/plugin-data.d.ts +11 -0
  33. package/dist/plugin-data.js +96 -0
  34. package/dist/plugins/compiler.d.ts +66 -0
  35. package/dist/plugins/compiler.js +428 -0
  36. package/dist/plugins/data.d.ts +12 -0
  37. package/dist/plugins/data.js +120 -0
  38. package/dist/result.d.ts +1 -1
  39. package/dist/result.js +1 -0
  40. package/dist/runtime.d.ts +22 -0
  41. package/dist/runtime.js +18 -0
  42. package/dist/schema.d.ts +566 -82
  43. package/dist/schema.js +65 -53
  44. package/dist/scope.js +14 -5
  45. package/dist/step-identity.d.ts +1 -1
  46. package/dist/step-identity.js +1 -1
  47. package/dist/themes.d.ts +7 -0
  48. package/dist/themes.js +5 -0
  49. package/dist/traits.d.ts +7 -0
  50. package/dist/traits.js +26 -0
  51. package/dist/validate.js +17 -4
  52. package/dist/voice.d.ts +8 -2
  53. package/dist/voice.js +14 -2
  54. package/package.json +7 -4
  55. package/dist/diagram/elk.d.ts +0 -6
  56. package/dist/diagram/elk.js +0 -56
  57. package/dist/diagram/graph-layout.d.ts +0 -123
  58. package/dist/diagram/graph-layout.js +0 -620
  59. package/dist/diagram/index.d.ts +0 -41
  60. package/dist/diagram/index.js +0 -92
  61. package/dist/diagram/model.d.ts +0 -217
  62. package/dist/diagram/model.js +0 -189
  63. package/dist/diagram/sequence-layout.d.ts +0 -12
  64. package/dist/diagram/sequence-layout.js +0 -185
@@ -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;