@bpmn-nova/studio 0.3.5-preview → 0.3.6-preview

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/README.md CHANGED
@@ -4,32 +4,21 @@ BPMN Nova 的 Vanilla JavaScript / TypeScript 完整入口,提供流程设计
4
4
 
5
5
  > **English summary:** The complete framework-neutral BPMN Nova package for process design, viewing, approval traces, themes, properties, and pure SVG export.
6
6
 
7
- > 当前版本为 `0.3.5-preview`。请使用 `@preview` 安装,并在生产接入前验证目标 BPMN XML 与引擎扩展。
7
+ > 当前版本为 `0.3.6-preview`。请使用 `@preview` 安装,并在生产接入前验证目标 BPMN XML 与引擎扩展。
8
8
 
9
9
  ![BPMN Nova 流程设计器](https://raw.githubusercontent.com/daxiangme/bpmn-nova/dev/docs/assets/bpmn-nova-designer.jpg)
10
10
 
11
- ## 什么时候使用
12
-
13
- - Vanilla JavaScript 或 TypeScript 项目安装本包。
14
- - React 18+ 项目安装 `@bpmn-nova/react`。
15
- - Vue 3.3+ 项目安装 `@bpmn-nova/vue`。
16
- - 一个项目只需要选择一个公开包,不需要安装 Core、Viewer、Runtime、Theme 等内部 Module。
17
-
18
11
  ## 安装
19
12
 
20
13
  ```bash
21
14
  npm install @bpmn-nova/studio@preview
22
15
  ```
23
16
 
24
- ```js
25
- import '@bpmn-nova/studio/styles.css'
26
- ```
27
-
28
- BPMN Nova 不会在 JavaScript 中隐式注入 CSS。视觉容器必须有明确高度。
17
+ Vanilla JavaScript / TypeScript 项目选择本包;React 18+ 和 Vue 3.3+ 项目分别选择 `@bpmn-nova/react` 或 `@bpmn-nova/vue`。
29
18
 
30
- 使用代码生成助手或 IDE Agent 接入时,从随包的 `llms.txt` 开始;需要完整接口和定制资料时再读取 `llms-full.txt`。两份文件都包含在 npm tarball 中,不依赖源码仓库可见性。
19
+ CSS 必须显式导入 `@bpmn-nova/studio/styles.css`;视觉容器及其父级需要具有可计算高度。
31
20
 
32
- ## 流程设计
21
+ ## 最小用法
33
22
 
34
23
  ```html
35
24
  <div id="studio" style="height: 720px"></div>
@@ -43,374 +32,34 @@ import {
43
32
  } from '@bpmn-nova/studio'
44
33
  import '@bpmn-nova/studio/styles.css'
45
34
 
46
- const model = createEmptyProcess('flowable')
47
- model.id = 'Process_PurchaseApproval'
48
- model.name = '采购申请审批流程'
49
-
50
- const config = {
51
- modeling: {
52
- allowedNodeTypes: ['startEvent', 'userTask', 'exclusiveGateway', 'endEvent'],
53
- allowedEdgeTypes: ['sequenceFlow'],
54
- },
55
- ui: { controlSize: 'medium' },
56
- }
57
-
58
35
  const studio = createStudioController({
59
- model,
60
- config,
36
+ model: createEmptyProcess('flowable'),
61
37
  })
62
38
  const shell = createStudioShell({
63
39
  container: document.querySelector('#studio'),
64
40
  studio,
65
- config,
66
- mode: 'design',
67
- allowedModes: ['design'],
68
- theme: 'auto',
69
- })
70
-
71
- const xml = studio.exportXml()
72
-
73
- // 页面卸载时释放实例。
74
- shell.destroy()
75
- studio.destroy()
76
- ```
77
-
78
- `allowedNodeTypes` 与 `allowedEdgeTypes` 同时约束 XML 导入、Palette、连接、快捷新增、模板和节点类型转换;不传时开放 Nova 当前支持的全部图元。`allowedModes` 控制默认工作台显示和允许切换的模式。不传 Runtime 时实例模式保持空运行事实,不会注入演示审批数据。
79
-
80
- ## 嵌入宿主工作台
81
-
82
- 默认 `BpmnStudioShell` 仍是包含 Header、Palette、Canvas、Properties 和 Statusbar 的完整工作台。宿主要复用自己的业务属性面板时,应显式隐藏 Nova 右侧区域,并把业务面板作为 Nova 根节点的外部兄弟区域:
83
-
84
- ```js
85
- const shell = createStudioShell({
86
- container: novaHost,
87
- studio,
88
- config: {
89
- ui: { controlSize: 'medium', regions: { right: 'hidden' } },
90
- },
91
41
  mode: 'design',
92
42
  allowedModes: ['design'],
93
- slots: {
94
- headerStart({ container, actions, getState, subscribe }) {
95
- // 在 Nova Header 左侧挂载宿主的返回入口、业务图标、流程名称和类型。
96
- // 完整替换 Header 时改用 slots.header,并继续调用 actions。
97
- },
98
- headerActions({ container, actions, getMode, subscribeMode, ui }) {
99
- // 替换默认“校验 / 导入 / 导出”,在这里挂载宿主的“校验 / 保存 / 发布”。
100
- // 校验按钮调用 actions.validate();保存和发布继续调用宿主服务。
101
- },
102
- },
103
- theme: 'auto',
104
- })
105
-
106
- shell.setRegions({ right: 'default' })
107
- shell.actions.undo()
108
- shell.actions.redo()
109
- shell.actions.fitView()
110
- const issues = shell.actions.validate()
111
- const xml = shell.actions.exportXml('flowable')
112
- ```
113
-
114
- `regions` 支持 `header`、`left`、`right`、`footer` 的 `default | hidden` 状态;隐藏区域不占布局轨道,也不保留折叠按钮。Design 默认显示左右,Viewer 仅右侧,Instance 默认隐藏两侧;显式 `regions.right: 'default'` 可在 Instance 开启右侧。`setRegions()` 原地更新默认 Shell,不重建 Controller 或 Canvas。`layout()` 是完整布局替换,不能与 `regions` 同时使用。
115
-
116
- `headerActions` 只替换 Header 最右侧动作组,`headerStart` 可与其同时使用,完整 `header` 的优先级更高。未提供 `headerActions` 时仍显示默认“校验 / 导入 / 导出”。顶部不再重复显示最佳视图;底部缩放区和 `fitView()` Interface 保持不变。
117
-
118
- `shell.actions.validate()` 作为 Header 动作,以 `toolbar` 来源先更新 Nova 默认状态栏、再发送 Validation Event,最后返回 issues;程序化调用 `shell.validate()` 使用 `api` 来源。`valid` 表示没有 error,warning 不默认阻止发布:
119
-
120
- ```js
121
- const offValidation = shell.subscribeValidation((event) => {
122
- console.log(event.source, event.valid, event.errorCount, event.warningCount, event.issues)
123
- })
124
-
125
- shell.validate()
126
- offValidation()
127
- ```
128
-
129
- 宿主发布按钮可以复用 Toolbar 来源的完整流程;仅 error 默认阻止发布:
130
-
131
- ```js
132
- async function publishProcess(actions) {
133
- const issues = actions.validate()
134
- if (issues.some((issue) => issue.level === 'error')) return
135
- await publishXml(actions.exportXml())
136
- }
137
- ```
138
-
139
- `shell.actions` 只封装撤销、重做、布局、视图、校验和 BPMN/SVG 导入导出。宿主的保存草稿、发布、权限、文件选择和服务端事务不属于 Nova Actions。
140
-
141
- ## 侧栏内容与平滑折叠
142
-
143
- `slots.right` 只替换内容,Nova 保留宽度管理和分隔线中点折叠按钮;不要同时将 `regions.right` 设置为 `hidden`,否则自定义内容也隐藏。`config.ui.rightPanel.layout` 默认 `flex`,宿主安排固定头尾和 `flex: 1; min-height: 0; overflow: auto` 内容区;改为 `scroll` 时由 Nova 滚动整个内容。
144
-
145
- ```js
146
- const shell = createStudioShell({
147
- container,
148
- studio,
149
- config: { ui: {
150
- leftPanel: { collapsible: true, defaultCollapsed: false },
151
- rightPanel: { collapsible: true, defaultCollapsed: false, layout: 'scroll' },
152
- } },
153
- slots: {
154
- right({ container, shell }) {
155
- const text = document.createElement('p')
156
- container.append(text)
157
- const render = ({ selectedElement }) => { text.textContent = selectedElement?.id ?? '未选择元素' }
158
- render(shell.getPanelSelection())
159
- const off = shell.subscribePanelSelection(render)
160
- return () => { off(); text.remove() }
161
- },
162
- },
163
- })
164
- const offSidebar = shell.subscribeSidebarChange(({ side, collapsed, source }) => console.log(side, collapsed, source))
165
- shell.setSidebarCollapsed('left', true)
166
- console.log(shell.getSidebarState().left)
167
- // 卸载时 offSidebar(); shell.destroy(); studio.destroy()
168
- ```
169
-
170
- 默认左右可独立折叠;200ms 动画尊重减少动态效果,不卸载内容、不丢失表单和滚动状态、不自动 Fit。Shell 容器 ≤720px 时首次默认收起并保留按钮,展开挤压画布,宽窄屏分别记忆状态。`defaultCollapsed` 只用于初始化;隐藏不同于收起。`panelSelection` 包含 `{ selection, selectedElement, trace }`,Design 从 Controller 派生,Viewer/Instance 从实际点击派生而不回写设计选择。
171
-
172
- 完整配置、事件契约、窄屏与 Flex 样式见仓库 [CUSTOMIZATION.md](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/CUSTOMIZATION.md#侧栏布局与平滑折叠),或包内 `llms-full.txt` 同名章节。上述新增能力自 `0.3.5-preview` 提供。
173
-
174
- ## Config 与 Header 控件尺寸
175
-
176
- `config` 统一承载静态配置:`modeling` 是 Controller 初始化约束,`ui` 是 Shell 区域和尺寸,`viewer` 是只读/实例展示选项,`export` 是 SVG 导出默认值。`config.ui.controlSize` 默认 `medium`,支持 `small`(28px)、`medium`(32px)、`large`(40px)和 `24px`–`48px` 的 CSS 像素字符串。
177
-
178
- ```js
179
- shell.setConfig({
180
- ui: {
181
- controlSize: '36px',
182
- regions: { right: 'hidden' },
183
- sidebarWidth: { left: 232, right: 344 },
184
- },
185
- viewer: { responsive: true },
186
- export: { padding: 36 },
187
- })
188
-
189
- console.log(shell.getConfig())
190
- console.log(shell.ui.controlSize, shell.ui.controlHeight) // 36px, 36px
191
- ```
192
-
193
- 尺寸只作用于 Header;Footer、Canvas 浮动工具、Palette 和 Properties 不随之缩放。Header Slot 可读取只读 `ui`,并继承 `--nova-control-height`、`--nova-header-height`、`--nova-control-font-size`、`--nova-control-padding-inline`、`--nova-control-icon-size` 和 `--nova-control-radius`。Element Plus `default`、Ant Design `middle` 都对应 Nova `medium`。
194
-
195
- 旧顶层配置仍兼容但已 Deprecated;同一字段同时出现时旧顶层显式值优先。`setConfig()` 原地应用 UI、Viewer 和 Export,不重建 Canvas;`config.modeling` 只在创建 Controller 时生效,运行中继续通过 `setPropertiesProfile()` 修改 Profile,节点/连线白名单保持不变量。
196
-
197
- ## Mode 与节点副标题投影
198
-
199
- `design`、`viewer`、`instance` 分别表示流程设计、流程展示和审批轨迹。Shell 是唯一 Mode 状态源:
200
-
201
- ```js
202
- const unsubscribe = shell.subscribeMode((event) => {
203
- console.log(event.mode, event.previousMode, event.source, event.allowedModes)
204
- })
205
-
206
- shell.getMode()
207
- shell.setMode('viewer')
208
- shell.setAllowedModes(['design', 'viewer'])
209
- ```
210
-
211
- `setMode()` 仅在实际成功切换时返回 `true`。`setAllowedModes()` 拒绝空数组、重复值和未知值;若移除当前 Mode,会回退到新数组首项并发送一次 `allowed-modes` 事件。切换只改变 Shell 展示,不进入 Model、History 或 Studio State。
212
-
213
- 标准任务与容器卡片支持定义态副标题 Resolver:
214
-
215
- ```js
216
- const summaries = new Map()
217
- const shell = createStudioShell({
218
- container,
219
- studio,
220
- nodeSubtitleResolver({ node, mode, surface, defaultSubtitle }) {
221
- return summaries.has(node.id) ? summaries.get(node.id) : undefined
222
- },
223
- })
224
-
225
- summaries.set('ServiceTask_Archive', '归档到采购系统')
226
- shell.refreshPresentation()
227
- summaries.set('ServiceTask_Archive', null)
228
- shell.refreshPresentation()
229
- ```
230
-
231
- `undefined` 保留默认副标题,`null` 移除副标题行,字符串(包括空字符串)作为覆盖值。Resolver 同步应用于 Design、Viewer 与标准 SVG 降级视觉;完整自定义 Renderer 优先,Instance 始终使用 Runtime Presentation。`refreshPresentation()` 不写 XML、不创建历史、不改变选择、Scope 或视口。
232
-
233
- ## 只读 Viewer
234
-
235
- ```js
236
- import { importBpmn } from '@bpmn-nova/studio'
237
- import { BpmnViewer } from '@bpmn-nova/studio/viewer'
238
- import '@bpmn-nova/studio/styles.css'
239
-
240
- const viewer = new BpmnViewer({
241
- container: document.querySelector('#viewer'),
242
- model: importBpmn(xml, 'flowable'),
243
- projection: 'standard',
244
43
  theme: 'auto',
245
44
  })
246
45
 
247
- viewer.fitView()
248
- viewer.destroy()
249
- ```
250
-
251
- 也可以从 `@bpmn-nova/studio` 根入口导入所有公开 Interface;子路径用于明确表达接入场景。
252
-
253
- ![BPMN Nova 只读流程展示](https://raw.githubusercontent.com/daxiangme/bpmn-nova/dev/docs/assets/bpmn-nova-viewer.jpg)
254
-
255
- ## 审批轨迹
256
-
257
- 完整 XML、Snapshot、宿主转换器及 Core 生命周期示例见[审批轨迹接入指南](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/RUNTIME-INTEGRATION.md),正文也包含在包内 `llms-full.txt`。Studio 现有 Runtime 类型出口保持不变;Vue/React 自 `0.3.5-preview` 提供的新增类型出口和旧版兼容写法在指南中单独说明。
258
-
259
- Viewer 接收引擎中立的 Runtime Snapshot。三种投影使用相同数据:
260
-
261
- | 投影 | 配置 | 适用场景 |
262
- | --- | --- | --- |
263
- | 实际路径 | `projection: 'approval'` | 只展示实际发生的有效路径 |
264
- | 移动时间线 | `projection: 'compact'` | 按访问轮次展示动作、图片和附件 |
265
- | 完整 BPMN | `projection: 'standard'` + `runtime` | 完整结构叠加运行状态 |
266
-
267
- ```js
268
- const runtime = {
269
- processInstanceId: 'purchase-20260824',
270
- status: 'running',
271
- activities: [{
272
- id: 'activity-manager-1',
273
- elementId: 'UserTask_Manager',
274
- visitId: 'visit-manager-1',
275
- status: 'completed',
276
- assignee: '李经理',
277
- endTime: '2026-08-24T10:12:00+08:00',
278
- }],
279
- actions: [{
280
- id: 'action-manager-approve',
281
- type: 'approve',
282
- elementId: 'UserTask_Manager',
283
- visitId: 'visit-manager-1',
284
- activityId: 'activity-manager-1',
285
- actor: { id: 'manager-li', name: '李经理' },
286
- occurredAt: '2026-08-24T10:12:00+08:00',
287
- content: {
288
- plainText: '资料完整,同意提交总经理审批。',
289
- blocks: [
290
- { type: 'paragraph', text: '资料完整,同意提交总经理审批。' },
291
- { type: 'image', assetId: 'quotation-preview' },
292
- { type: 'file', assetId: 'purchase-checklist' },
293
- ],
294
- assets: [
295
- {
296
- id: 'quotation-preview',
297
- name: '现场报价单.png',
298
- mediaType: 'image/png',
299
- width: 1280,
300
- height: 720,
301
- },
302
- {
303
- id: 'purchase-checklist',
304
- name: '采购核验清单.txt',
305
- mediaType: 'text/plain',
306
- size: 248,
307
- },
308
- ],
309
- },
310
- }],
311
- visitedEdges: [],
312
- }
313
-
314
- const runtimeAssetResolver = async (asset, { purpose, signal }) => {
315
- const response = await fetch(
316
- `/api/runtime-assets/${encodeURIComponent(asset.id)}?purpose=${purpose}`,
317
- { signal },
318
- )
319
- if (!response.ok) return null
320
- return response.url
46
+ function dispose() {
47
+ shell.destroy()
48
+ studio.destroy()
321
49
  }
322
-
323
- viewer.setRuntime(runtime)
324
- viewer.setProjection('compact')
325
- viewer.setDisplayOptions({ runtimeAssetResolver })
326
- ```
327
-
328
- Snapshot 只保存资源引用,不保存 URL、Base64、Blob 或 HTML。上传、权限签发和资源存储由宿主业务系统负责。
329
-
330
- | 实际路径 | 移动时间线 |
331
- | --- | --- |
332
- | ![审批实际路径](https://raw.githubusercontent.com/daxiangme/bpmn-nova/dev/docs/assets/bpmn-nova-approval-effective-path.jpg) | ![移动审批时间线](https://raw.githubusercontent.com/daxiangme/bpmn-nova/dev/docs/assets/bpmn-nova-approval-mobile-timeline.jpg) |
333
-
334
- ![完整 BPMN 审批轨迹](https://raw.githubusercontent.com/daxiangme/bpmn-nova/dev/docs/assets/bpmn-nova-approval-full-bpmn.jpg)
335
-
336
- ## 主题与运行态配色
337
-
338
- ```js
339
- shell.setTheme({
340
- mode: 'auto',
341
- dark: {
342
- colors: {
343
- canvas: '#0b1018',
344
- surface: '#18202b',
345
- },
346
- },
347
- })
348
-
349
- shell.setRuntimeAppearance({
350
- statuses: { completed: 'success', active: 'primary' },
351
- actions: {
352
- approve: { label: '通过', tone: 'success' },
353
- reject: { label: '驳回', tone: 'danger' },
354
- },
355
- })
356
- ```
357
-
358
- 主题限定在实例根节点;`auto` 会跟随并监听浏览器系统主题变化,不修改宿主页面的 `<html>`。
359
-
360
- ![BPMN Nova 深色运行态](https://raw.githubusercontent.com/daxiangme/bpmn-nova/dev/docs/assets/bpmn-nova-dark-runtime.jpg)
361
-
362
- ## SVG 导出
363
-
364
- ```js
365
- // 打开确认预览,用户确认后下载。
366
- shell.openSvgExportPreview({
367
- theme: 'current',
368
- transparentBackground: false,
369
- filename: '采购申请审批流程.svg',
370
- })
371
-
372
- // 或只创建 Artifact,不触发下载。
373
- const artifact = await shell.exportSvg({ theme: 'dark' })
374
- console.log(artifact.svg, artifact.warnings)
375
50
  ```
376
51
 
377
- 导出完整业务内容,不受当前缩放、平移或滚动影响。图片会通过 Resolver 嵌入 SVG,普通附件只展示摘要。
378
-
379
- ![SVG 导出确认预览](https://raw.githubusercontent.com/daxiangme/bpmn-nova/dev/docs/assets/bpmn-nova-svg-export-preview.jpg)
380
-
381
- ## 支持的子路径
382
-
383
- ```js
384
- import { BpmnDesigner } from '@bpmn-nova/studio/designer'
385
- import { BpmnViewer } from '@bpmn-nova/studio/viewer'
386
- import { createRuntimePresentation } from '@bpmn-nova/studio/runtime'
387
- import { createThemeController } from '@bpmn-nova/studio/theme'
388
- import { exportDiagramSvg } from '@bpmn-nova/studio/export-svg'
389
- import { flowableProfile } from '@bpmn-nova/studio/flowable'
390
- import { activitiProfile } from '@bpmn-nova/studio/activiti'
391
- ```
392
-
393
- ## 常见问题
394
-
395
- - **界面为空或高度为 0:** 为 Studio/Viewer 的父容器设置明确高度。
396
- - **界面没有样式:** 导入一次 `@bpmn-nova/studio/styles.css`。
397
- - **附件不可用:** 提供 `runtimeAssetResolver`,并为不同 purpose 返回当前有效地址。
398
- - **SSR 报错:** 在浏览器挂载阶段创建实例,服务端只准备 XML 和 Runtime 数据。
399
- - **重复安装:** 不直接安装任何未列出的 `@bpmn-nova/*` 内部 Module。
400
-
401
- ## 文档与 AI
52
+ 在页面卸载时调用 `dispose()`;SSR 应用只在客户端创建视觉实例。
402
53
 
403
- - npm 包内 `llms.txt`:可执行安装入口
404
- - npm 包内 `llms-full.txt`:完整 AI 上下文
405
- - [项目首页](https://github.com/daxiangme/bpmn-nova)
406
- - [快速开始](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/GETTING-STARTED.md)
407
- - [公开 Interface](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/API.md)
408
- - [审批轨迹接入指南](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/RUNTIME-INTEGRATION.md)
409
- - [自定义指南](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/CUSTOMIZATION.md)
54
+ ## 完整文档
410
55
 
411
- ## 能力边界
56
+ - [官网与文档](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/index.md)
57
+ - [Studio 接入、宿主组合和完整示例](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/guide/studio.md)
58
+ - [组件参数与事件](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/components/index.md)、[公开 API](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/api/index.md)
59
+ - [审批轨迹接入](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/guide/runtime.md)、[自定义扩展](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/customization/index.md)
60
+ - [更新日志](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/changelog.md)
412
61
 
413
- BPMN Nova 负责建模、展示、审批轨迹、主题和 SVG 导出;不负责流程引擎执行、审批提交、附件上传存储、权限签发或 PNG/PDF 导出。当前 Preview 不声明 BPMN Schema 100% 覆盖。
62
+ 官网尚未部署,以上链接暂指向仓库文档。AI 接入从随包的 `llms.txt` 开始;`llms-full.txt` 提供完整离线上下文,两份文件都包含在 npm tarball 中。
414
63
 
415
64
  ## License
416
65
 
@@ -2,7 +2,7 @@ import { NODE_DEFINITIONS, edgeWaypoints, roundedPath, routeRuntimeTransition, s
2
2
  import { createDefaultIconRegistry, resolveNodeVisual } from '../icons/index.js';
3
3
  import { resolveNodeSubtitle, supportsNodeSubtitle } from '../node-presentation/index.js';
4
4
  import { resolveNodeGeometry, resolvePresentationWaypoints } from '../node-geometry/index.js';
5
- import { createRuntimePresentation } from '../runtime/index.js';
5
+ import { createRuntimePresentation, formatRuntimeInstant } from '../runtime/index.js';
6
6
  import { createRuntimeAppearance } from '../theme/index.js';
7
7
 
8
8
  const SVG_NS = 'http://www.w3.org/2000/svg';
@@ -170,7 +170,7 @@ function finite(value, fallback = 0) {
170
170
  }
171
171
 
172
172
  function formatTime(value) {
173
- return value ? String(value).replace('T', ' ') : '';
173
+ return formatRuntimeInstant(value);
174
174
  }
175
175
 
176
176
  function formatSize(value) {
@@ -737,6 +737,7 @@ export class DiagramRenderer {
737
737
  const boundsW = maxX - minX || 1;
738
738
  const boundsH = maxY - minY || 1;
739
739
  const rect = this.viewport.getBoundingClientRect();
740
+ if (rect.width < 1 || rect.height < 1) return;
740
741
  const maxZoom = options.maxZoom ?? 1.15;
741
742
  const minZoom = options.minZoom ?? 0.25;
742
743
  const rawZoom = Math.min((rect.width - padding * 2) / boundsW, (rect.height - padding * 2) / boundsH, maxZoom);
@@ -0,0 +1,22 @@
1
+ const DIAGNOSTIC_FIELDS = ['code', 'level', 'message', 'fieldPath', 'elementId', 'activityId', 'visitId', 'actionId', 'transitionId', 'edgeId'];
2
+
3
+ export function createDiagnostic(input = {}) {
4
+ const diagnostic = {
5
+ code: String(input.code || 'runtime-issue'),
6
+ level: input.level === 'error' || input.level === 'info' ? input.level : 'warning',
7
+ message: String(input.message || ''),
8
+ };
9
+ for (const field of DIAGNOSTIC_FIELDS.slice(3)) {
10
+ if (input[field]) diagnostic[field] = String(input[field]);
11
+ }
12
+ return Object.freeze(diagnostic);
13
+ }
14
+
15
+ export function pushDiagnostic(list, input) {
16
+ if (!list) return null;
17
+ const diagnostic = createDiagnostic(input);
18
+ if (!list.some((item) => item.code === diagnostic.code && item.fieldPath === diagnostic.fieldPath && item.activityId === diagnostic.activityId && item.visitId === diagnostic.visitId && item.actionId === diagnostic.actionId && item.transitionId === diagnostic.transitionId)) {
19
+ list.push(diagnostic);
20
+ }
21
+ return diagnostic;
22
+ }
@@ -51,9 +51,27 @@ export interface RuntimeApprovalActionPresentation extends Omit<RuntimeApprovalA
51
51
  assetCount: number
52
52
  order: number
53
53
  }
54
+ export interface RuntimeDiagnostic {
55
+ code: string
56
+ level: 'error' | 'warning' | 'info'
57
+ message: string
58
+ fieldPath?: string
59
+ elementId?: string
60
+ activityId?: string
61
+ visitId?: string
62
+ actionId?: string
63
+ transitionId?: string
64
+ edgeId?: string
65
+ }
66
+ export interface RuntimeInstant {
67
+ instant: number | null
68
+ raw: string
69
+ kind: 'offset' | 'z' | 'naive' | 'invalid' | 'missing'
70
+ }
54
71
  export interface RuntimeApprovalActionSummary {
55
72
  actions: RuntimeApprovalActionPresentation[]
56
73
  latestAction: RuntimeApprovalActionPresentation | null
74
+ latestNonEmptyComment: RuntimeApprovalActionPresentation | null
57
75
  actionText: string
58
76
  actionSummary: string
59
77
  imageCount: number
@@ -70,6 +88,7 @@ export interface ActivityInstance {
70
88
  assigneeId?: string
71
89
  participant?: RuntimeParticipant
72
90
  visitId?: string
91
+ supersedesVisitId?: string
73
92
  multiInstanceId?: string
74
93
  approvalMode?: 'single' | 'all' | 'any'
75
94
  multiInstanceMode?: 'parallel' | 'sequential'
@@ -92,6 +111,7 @@ export interface RuntimeTransition {
92
111
  state?: 'active' | 'resolved'
93
112
  resolvedAt?: string
94
113
  resolvedByActivityId?: string
114
+ invalidatedElementIds?: string[]
95
115
  invalidatedActivityIds?: string[]
96
116
  invalidatedEdgeIds?: string[]
97
117
  }
@@ -120,10 +140,18 @@ export interface RuntimeTransitionPresentation extends RuntimeTransition {
120
140
  label: string
121
141
  latest: boolean
122
142
  issues: string[]
143
+ invalidatedElementIds: string[]
123
144
  invalidatedActivityIds: string[]
124
145
  invalidatedEdgeIds: string[]
125
146
  action: RuntimeApprovalActionPresentation | null
126
147
  }
148
+ export interface ActivityVisitState {
149
+ status: ActivityStatus
150
+ records: ActivityInstance[]
151
+ latestRecords: ActivityInstance[]
152
+ visits: Array<{ id: string; round: number; records: ActivityInstance[]; effective?: boolean; superseded?: boolean }>
153
+ effectiveVisits: Array<{ id: string; round: number; records: ActivityInstance[]; effective?: boolean; superseded?: boolean }>
154
+ }
127
155
  export interface NodeRuntimePresentation extends RuntimeApprovalActionSummary {
128
156
  elementId: string
129
157
  status: ActivityStatus | 'rejected'
@@ -141,13 +169,15 @@ export interface NodeRuntimePresentation extends RuntimeApprovalActionSummary {
141
169
  round: number
142
170
  records: ActivityInstance[]
143
171
  latestRecords: ActivityInstance[]
144
- visits: Array<{ id: string; round: number; records: ActivityInstance[] } & RuntimeApprovalActionSummary>
172
+ visits: Array<{ id: string; round: number; records: ActivityInstance[]; effective: boolean; superseded: boolean } & RuntimeApprovalActionSummary>
173
+ effectiveVisits: Array<{ id: string; round: number; records: ActivityInstance[]; effective: boolean; superseded: boolean } & RuntimeApprovalActionSummary>
145
174
  transitions: RuntimeTransitionPresentation[]
146
175
  isReentry: boolean
147
176
  hasDetails: boolean
148
177
  }
149
178
  export interface RuntimePresentation {
150
179
  runtime: ProcessInstanceSnapshot
180
+ diagnostics: readonly RuntimeDiagnostic[]
151
181
  getNode(elementId: string): NodeRuntimePresentation
152
182
  getEdge(edgeId: string): { edgeId: string; status: ActivityStatus; visited: boolean; historicallyVisited: boolean; superseded: boolean }
153
183
  getAction(actionId: string): RuntimeApprovalActionPresentation | null
@@ -161,9 +191,13 @@ export interface RuntimeAppearanceLike {
161
191
  resolveTransition(transition?: { type?: string }): { tone: string }
162
192
  }
163
193
 
164
- export function normalizeRuntime(snapshot?: Partial<ProcessInstanceSnapshot> | null): ProcessInstanceSnapshot
165
- export function activityState(runtime: ProcessInstanceSnapshot | null | undefined, elementId: string): ActivityStatus
166
- export function createRuntimePresentation(context: { model: ProcessModel; runtime?: ProcessInstanceSnapshot | null; appearance?: RuntimeAppearanceLike | null }): RuntimePresentation
194
+ export function parseRuntimeInstant(value?: string | null): RuntimeInstant
195
+ export function formatRuntimeInstant(value?: string | RuntimeInstant | null): string
196
+ export function compareRuntimeOrder(left: { instant?: number | null; index?: number } | string | null | undefined, right: { instant?: number | null; index?: number } | string | null | undefined): number
197
+ export function normalizeRuntime(snapshot?: Partial<ProcessInstanceSnapshot> | null, options?: { diagnostics?: RuntimeDiagnostic[]; model?: ProcessModel | null }): ProcessInstanceSnapshot
198
+ export function activityState(runtime: ProcessInstanceSnapshot | null | undefined, elementId: string, options?: { diagnostics?: RuntimeDiagnostic[] }): ActivityVisitState
199
+ export function inspectRuntime(snapshot?: Partial<ProcessInstanceSnapshot> | null, options?: { model?: ProcessModel | null; appearance?: RuntimeAppearanceLike | null }): { runtime: ProcessInstanceSnapshot; diagnostics: readonly RuntimeDiagnostic[] }
200
+ export function createRuntimePresentation(context: { model: ProcessModel; runtime?: ProcessInstanceSnapshot | null; appearance?: RuntimeAppearanceLike | null; diagnostics?: RuntimeDiagnostic[] }): RuntimePresentation
167
201
  export function demoRuntime(): ProcessInstanceSnapshot
168
202
 
169
203
  export type RuntimeElement = BpmnNode | BpmnEdge