@bpmn-nova/studio 0.3.9-preview → 0.4.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 (55) hide show
  1. package/README.md +2 -2
  2. package/dist/canvas.js +97 -25
  3. package/dist/config.js +13 -0
  4. package/dist/context-menu.js +41 -32
  5. package/dist/controller.js +45 -19
  6. package/dist/index.d.ts +47 -2
  7. package/dist/index.js +1 -0
  8. package/dist/interactions.js +6 -1
  9. package/dist/modules/bpmn-model/index.d.ts +2 -1
  10. package/dist/modules/bpmn-model/index.js +12 -10
  11. package/dist/modules/core/gateway.js +16 -13
  12. package/dist/modules/core/index.d.ts +6 -4
  13. package/dist/modules/core/model.js +12 -7
  14. package/dist/modules/designer/index.d.ts +5 -1
  15. package/dist/modules/designer/index.js +36 -15
  16. package/dist/modules/export-svg/index.d.ts +12 -5
  17. package/dist/modules/export-svg/preview.js +34 -24
  18. package/dist/modules/export-svg/render.js +102 -50
  19. package/dist/modules/i18n/index.d.ts +647 -0
  20. package/dist/modules/i18n/index.js +247 -0
  21. package/dist/modules/i18n/locales/en-US.js +823 -0
  22. package/dist/modules/i18n/locales/zh-CN.js +805 -0
  23. package/dist/modules/node-presentation/index.d.ts +3 -2
  24. package/dist/modules/node-presentation/index.js +14 -11
  25. package/dist/modules/palette/index.d.ts +6 -1
  26. package/dist/modules/palette/index.js +26 -8
  27. package/dist/modules/palette/panel.js +44 -6
  28. package/dist/modules/properties/index.d.ts +2 -1
  29. package/dist/modules/properties/index.js +2 -2
  30. package/dist/modules/properties-activiti/index.js +84 -59
  31. package/dist/modules/properties-bpmn/index.js +151 -128
  32. package/dist/modules/properties-core/index.d.ts +9 -3
  33. package/dist/modules/properties-core/index.js +16 -4
  34. package/dist/modules/properties-flowable/index.js +55 -34
  35. package/dist/modules/properties-renderer/index.d.ts +5 -1
  36. package/dist/modules/properties-renderer/index.js +110 -42
  37. package/dist/modules/renderer-svg/index.d.ts +6 -2
  38. package/dist/modules/renderer-svg/index.js +113 -38
  39. package/dist/modules/runtime/index.d.ts +33 -5
  40. package/dist/modules/runtime/index.js +97 -73
  41. package/dist/modules/runtime/time.js +89 -4
  42. package/dist/modules/runtime/visits.js +6 -4
  43. package/dist/modules/theme/index.d.ts +5 -2
  44. package/dist/modules/theme/index.js +8 -4
  45. package/dist/modules/viewer/index.d.ts +28 -7
  46. package/dist/modules/viewer/index.js +213 -56
  47. package/dist/modules/viewer/runtime-content.js +26 -20
  48. package/dist/modules/viewer/runtime-trace.js +43 -25
  49. package/dist/modules/viewer/timeline.js +103 -36
  50. package/dist/shell.js +258 -75
  51. package/dist/sidebars.js +3 -1
  52. package/dist/styles.css +3 -2
  53. package/llms-full.txt +241 -46
  54. package/llms.txt +4 -4
  55. package/package.json +2 -3
@@ -1,4 +1,5 @@
1
1
  import { NODE_DEFINITIONS, PALETTE_GROUPS, PARALLEL_GATEWAY_PRESETS, edgeWaypoints, resolveGatewayRole, resolveSwimlaneLabelPlacement, roundedPath, routeRuntimeTransition, smoothPath } from '../core/index.js';
2
+ import { createI18n, resolveI18n } from '../i18n/index.js';
2
3
  import { createRuntimePresentation } from '../runtime/index.js';
3
4
  import { createDefaultIconRegistry, createIconElement, resolveNodeVisual } from '../icons/index.js';
4
5
  import { resolveNodeSubtitle, supportsNodeSubtitle } from '../node-presentation/index.js';
@@ -346,6 +347,13 @@ export class DiagramRenderer {
346
347
  this.options = options;
347
348
  this.themeController = options.themeController || new ThemeController({ root: container, theme: options.theme, onChange: options.onThemeChange });
348
349
  this._ownsThemeController = !options.themeController;
350
+ if (options.i18n) {
351
+ this.i18n = resolveI18n(options.i18n);
352
+ this._ownsI18n = false;
353
+ } else {
354
+ this.i18n = createI18n({ locale: options.locale, messages: options.messages });
355
+ this._ownsI18n = true;
356
+ }
349
357
  this.iconRegistry = options.iconRegistry || createDefaultIconRegistry();
350
358
  this._nodeContentCleanups = [];
351
359
  this.model = options.model || { nodes: [], edges: [] };
@@ -366,9 +374,24 @@ export class DiagramRenderer {
366
374
  this.svgExportOptions = options.svgExport || {};
367
375
  this._svgExportPreview = null;
368
376
  this._buildDom();
377
+ this._offI18n = options.autoSyncI18n !== false && typeof this.i18n.subscribe === 'function'
378
+ ? this.i18n.subscribe(() => {
379
+ this._syncEmptyStateText();
380
+ this.render();
381
+ })
382
+ : null;
369
383
  this.render();
370
384
  }
371
385
 
386
+ _t(key, params) {
387
+ return this.i18n.t(key, params);
388
+ }
389
+
390
+ _syncEmptyStateText() {
391
+ if (this._emptyStateTitle) this._emptyStateTitle.textContent = this._t('canvas.emptySubProcessTitle');
392
+ if (this._emptyStateHint) this._emptyStateHint.textContent = this._t('canvas.emptySubProcessHint');
393
+ }
394
+
372
395
  _buildDom() {
373
396
  this.container.innerHTML = '';
374
397
  this.container.classList.add('mb-diagram-host');
@@ -414,7 +437,9 @@ export class DiagramRenderer {
414
437
  this.viewport.append(this.world, this.marquee);
415
438
  this.emptyState = el('div', 'mb-scope-empty');
416
439
  this.emptyState.hidden = true;
417
- this.emptyState.append(el('strong', '', '空子流程'), el('span', '', '拖入节点或添加开始事件'));
440
+ this._emptyStateTitle = el('strong', '', this._t('canvas.emptySubProcessTitle'));
441
+ this._emptyStateHint = el('span', '', this._t('canvas.emptySubProcessHint'));
442
+ this.emptyState.append(this._emptyStateTitle, this._emptyStateHint);
418
443
  this.container.append(this.viewport, this.emptyState);
419
444
 
420
445
  this.viewport.addEventListener('wheel', (event) => {
@@ -668,6 +693,8 @@ export class DiagramRenderer {
668
693
  return true;
669
694
  }
670
695
  destroy() {
696
+ this._offI18n?.();
697
+ this._offI18n = null;
671
698
  this._svgExportPreview?.close?.({ immediate: true });
672
699
  this._svgExportPreview = null;
673
700
  this._nodeContentCleanups.splice(0).forEach((cleanup) => cleanup?.());
@@ -676,6 +703,23 @@ export class DiagramRenderer {
676
703
  if (this._ownsThemeController) this.themeController.destroy();
677
704
  }
678
705
 
706
+ setLocale(locale, messages) {
707
+ if (!this._ownsI18n) {
708
+ this._offI18n?.();
709
+ this.i18n = createI18n({ locale: locale ?? this.i18n.locale, messages });
710
+ this._ownsI18n = true;
711
+ this._offI18n = this.i18n.subscribe(() => {
712
+ this._syncEmptyStateText();
713
+ this.render();
714
+ });
715
+ this._syncEmptyStateText();
716
+ this.render();
717
+ return this.i18n.getState();
718
+ }
719
+ return this.i18n.setLocale(locale, messages);
720
+ }
721
+ getLocale() { return this.i18n.locale; }
722
+
679
723
  setTheme(theme) { return this.themeController.setTheme(theme); }
680
724
  setThemeMode(mode) { return this.themeController.setMode(mode); }
681
725
  getThemeState() { return this.themeController.getState(); }
@@ -697,6 +741,7 @@ export class DiagramRenderer {
697
741
  nodeSubtitleResolver: this.options.nodeSubtitleResolver,
698
742
  mode: this.mode,
699
743
  label: options.label || this.svgExportOptions.label,
744
+ i18n: this.i18n,
700
745
  }, { ...this.svgExportOptions, ...options });
701
746
  }
702
747
 
@@ -707,8 +752,9 @@ export class DiagramRenderer {
707
752
  }
708
753
  this._svgExportPreview = openSvgExportPreview({
709
754
  container: this.container,
710
- title: options.previewTitle || '导出 SVG',
755
+ title: options.previewTitle || this._t('exportSvg.preview.defaultTitle'),
711
756
  initialTheme: options.theme || 'current',
757
+ i18n: this.i18n,
712
758
  createArtifact: (previewOptions) => this.exportSvg({ ...options, ...previewOptions }),
713
759
  onClose: () => { this._svgExportPreview = null; },
714
760
  onDownload: options.onDownload,
@@ -797,8 +843,8 @@ export class DiagramRenderer {
797
843
  render() {
798
844
  const presenter = this.options.runtimePresenter || ((context) => createRuntimePresentation(context));
799
845
  this.runtimePresentation = this.runtime
800
- ? presenter({ model: this.model, runtime: this.runtime, appearance: this.options.runtimeAppearance })
801
- : createRuntimePresentation({ model: this.model, runtime: null, appearance: this.options.runtimeAppearance });
846
+ ? presenter({ model: this.model, runtime: this.runtime, appearance: this.options.runtimeAppearance, i18n: this.i18n })
847
+ : createRuntimePresentation({ model: this.model, runtime: null, appearance: this.options.runtimeAppearance, i18n: this.i18n });
802
848
  const subtitles = this._resolveDefinitionSubtitles();
803
849
  this._nodeGeometries = new Map(this.model.nodes.map((node) => [node.id, resolveNodeGeometry(node, NODE_DEFINITIONS[node.type])]));
804
850
  this._syncSceneBounds();
@@ -807,6 +853,7 @@ export class DiagramRenderer {
807
853
  this._renderGuides();
808
854
  this._renderNodes(subtitles);
809
855
  this._applyTransform();
856
+ this._syncEmptyStateText();
810
857
  this.container.dataset.mode = this.mode;
811
858
  if (this.emptyState) this.emptyState.hidden = this.model.nodes.length > 0 || !this.options.showEmptyState;
812
859
  }
@@ -827,6 +874,7 @@ export class DiagramRenderer {
827
874
  mode,
828
875
  surface: 'canvas',
829
876
  resolver: this.options.nodeSubtitleResolver,
877
+ i18n: this.i18n,
830
878
  }));
831
879
  }
832
880
  return subtitles;
@@ -880,7 +928,9 @@ export class DiagramRenderer {
880
928
  'data-transition-id': transition.id,
881
929
  role: 'button',
882
930
  tabindex: '0',
883
- 'aria-label': `${transition.label}${transition.operator ? `,操作人:${transition.operator}` : ''}`,
931
+ 'aria-label': transition.operator
932
+ ? this._t('canvas.runtimeTransitionAriaWithOperator', { label: transition.label, operator: transition.operator })
933
+ : this._t('canvas.runtimeTransitionAria', { label: transition.label }),
884
934
  });
885
935
  applyRuntimeTone(group, this.options.runtimeAppearance?.resolveTransition(transition).tone);
886
936
  const corner = this.model.settings?.cornerRadius ?? 14;
@@ -969,7 +1019,7 @@ export class DiagramRenderer {
969
1019
  const sourceNode = this.model.nodes.find((node) => node.id === edge.source);
970
1020
  const shouldShowPlaceholder = selected && sourceNode && NODE_DEFINITIONS[sourceNode.type]?.kind === 'gateway';
971
1021
  if (edge.name || shouldShowPlaceholder) {
972
- const textValue = edge.name || '设置分支名称';
1022
+ const textValue = edge.name || this._t('canvas.edgePlaceholder');
973
1023
  const metrics = edgeLabelMetrics(textValue);
974
1024
  const pos = edgeLabelPlacement(points, metrics, {
975
1025
  obstacles: [...nodeObstacles, ...labelObstacles],
@@ -1035,7 +1085,7 @@ export class DiagramRenderer {
1035
1085
  const input = document.createElementNS(XHTML_NS, 'input');
1036
1086
  input.className = 'mb-edge-label-input';
1037
1087
  input.value = edge.name || '';
1038
- input.placeholder = '输入分支名称';
1088
+ input.placeholder = this._t('canvas.edgeInputPlaceholder');
1039
1089
  wrap.appendChild(input);
1040
1090
  foreign.appendChild(wrap);
1041
1091
  this.edgeLabelSvg.appendChild(foreign);
@@ -1125,6 +1175,7 @@ export class DiagramRenderer {
1125
1175
  }
1126
1176
 
1127
1177
  _renderNodeShape(nodeEl, node, def, runtimeState, visual, subtitle) {
1178
+ const typeLabel = node.type ? this.i18n.elementTypeLabel(node.type, def.label) : def.label;
1128
1179
  if (def.kind === 'event' || def.kind === 'boundary') {
1129
1180
  const shape = el('div', 'mb-event-shape');
1130
1181
  shape.style.setProperty('--mb-event-shape-size', `${eventShapeDiameter(node, def)}px`);
@@ -1134,7 +1185,7 @@ export class DiagramRenderer {
1134
1185
  const glyph = el('span', 'mb-event-glyph');
1135
1186
  if (!this._renderCustomNodeContent(glyph, node, def, runtimeState, visual)) {
1136
1187
  const iconNode = visual.iconId
1137
- ? createIconElement(this.iconRegistry.resolve(visual.iconId, null), { className: 'mb-node-svg-icon', title: def.label })
1188
+ ? createIconElement(this.iconRegistry.resolve(visual.iconId, null), { className: 'mb-node-svg-icon', title: typeLabel })
1138
1189
  : null;
1139
1190
  if (iconNode) glyph.appendChild(iconNode);
1140
1191
  }
@@ -1155,21 +1206,30 @@ export class DiagramRenderer {
1155
1206
  const symbol = el('span', 'mb-gateway-symbol');
1156
1207
  if (!this._renderCustomNodeContent(symbol, node, def, runtimeState, visual)) {
1157
1208
  const iconNode = visual.iconId
1158
- ? createIconElement(this.iconRegistry.resolve(visual.iconId, null), { className: 'mb-node-svg-icon', title: def.label })
1209
+ ? createIconElement(this.iconRegistry.resolve(visual.iconId, null), { className: 'mb-node-svg-icon', title: typeLabel })
1159
1210
  : null;
1160
1211
  if (iconNode) symbol.appendChild(iconNode);
1161
1212
  }
1162
1213
  shape.appendChild(symbol);
1163
1214
  nodeEl.appendChild(shape);
1164
1215
  if (this.mode === 'design' && node.type === 'parallelGateway') {
1165
- const role = resolveGatewayRole(this.model, node);
1216
+ const role = resolveGatewayRole(this.model, node, { i18n: this.i18n });
1166
1217
  if (!role.topologyComplete) {
1167
- const marker = role.effective === 'Diverging' ? '分' : role.effective === 'Converging' ? '汇' : '?';
1218
+ const marker = this._t(role.effective === 'Diverging'
1219
+ ? 'canvas.gatewayRoleBadge.diverging'
1220
+ : role.effective === 'Converging'
1221
+ ? 'canvas.gatewayRoleBadge.converging'
1222
+ : 'canvas.gatewayRoleBadge.ambiguous');
1168
1223
  const badge = el('span', `mb-gateway-role-badge is-${role.status}`, marker);
1169
1224
  badge.dataset.gatewayRole = role.effective;
1170
1225
  badge.setAttribute('aria-hidden', 'true');
1171
- const statusLabel = { incomplete: '结构未完成', conflict: '结构冲突', ambiguous: '角色待判断', valid: '结构正常' }[role.status];
1172
- badge.title = `${role.effective === 'Diverging' ? '并行分支' : role.effective === 'Converging' ? '并行汇聚' : '角色待判断'} · ${statusLabel}`;
1226
+ const statusLabel = this._t(`canvas.gatewayRoleStatus.${role.status}`);
1227
+ const roleLabel = this._t(role.effective === 'Diverging'
1228
+ ? 'elementTypes.parallelDiverging'
1229
+ : role.effective === 'Converging'
1230
+ ? 'elementTypes.parallelConverging'
1231
+ : 'canvas.gatewayRoleStatus.ambiguous');
1232
+ badge.title = this._t('canvas.gatewayRoleTitle', { role: roleLabel, status: statusLabel });
1173
1233
  nodeEl.appendChild(badge);
1174
1234
  }
1175
1235
  }
@@ -1191,19 +1251,19 @@ export class DiagramRenderer {
1191
1251
 
1192
1252
  if (def.kind === 'annotation') {
1193
1253
  const annotation = el('div', 'mb-annotation-shape');
1194
- annotation.appendChild(el('div', 'mb-annotation-text', node.properties?.text || node.name || '说明'));
1254
+ annotation.appendChild(el('div', 'mb-annotation-text', node.properties?.text || node.name || this._t('canvas.defaultAnnotationCaption')));
1195
1255
  nodeEl.appendChild(annotation);
1196
1256
  return;
1197
1257
  }
1198
1258
 
1199
1259
  if (def.kind === 'group') {
1200
- nodeEl.appendChild(el('div', 'mb-container-caption', node.properties?.categoryValue || node.name || '分组'));
1260
+ nodeEl.appendChild(el('div', 'mb-container-caption', node.properties?.categoryValue || node.name || this._t('canvas.defaultGroupCaption')));
1201
1261
  return;
1202
1262
  }
1203
1263
 
1204
1264
  if (def.kind === 'participant' || def.kind === 'lane') {
1205
1265
  const rail = el('div', 'mb-swimlane-rail');
1206
- rail.appendChild(el('div', 'mb-swimlane-title', node.name || def.label));
1266
+ rail.appendChild(el('div', 'mb-swimlane-title', node.name || typeLabel));
1207
1267
  nodeEl.appendChild(rail);
1208
1268
  return;
1209
1269
  }
@@ -1219,7 +1279,7 @@ export class DiagramRenderer {
1219
1279
  const header = el('div', 'mb-node-header');
1220
1280
  const icon = visual.iconId ? el('span', 'mb-node-icon') : null;
1221
1281
  const iconNode = visual.iconId
1222
- ? createIconElement(this.iconRegistry.resolve(visual.iconId, null), { className: 'mb-node-svg-icon', title: def.label })
1282
+ ? createIconElement(this.iconRegistry.resolve(visual.iconId, null), { className: 'mb-node-svg-icon', title: typeLabel })
1223
1283
  : null;
1224
1284
  if (iconNode) icon.appendChild(iconNode);
1225
1285
  const titleWrap = el('div', `mb-node-title-wrap${this.mode === 'instance' ? ' mb-node-runtime-copy' : ''}`);
@@ -1228,7 +1288,7 @@ export class DiagramRenderer {
1228
1288
  event.stopPropagation();
1229
1289
  this.options.onRuntimeDetailsRequest?.({ node, presentation: runtimeState, anchor: event.currentTarget, event });
1230
1290
  };
1231
- titleWrap.appendChild(el('div', 'mb-node-title', node.name || def.label));
1291
+ titleWrap.appendChild(el('div', 'mb-node-title', node.name || typeLabel));
1232
1292
  const status = runtimeState.hasDetails ? el('button', `mb-runtime-status-icon status-${runtimeState.status}`) : el('span', `mb-runtime-status-icon status-${runtimeState.status}`);
1233
1293
  status.appendChild(uiIconElement(this.iconRegistry, runtimeStatusIconId(runtimeState), 'nova-icon nova-icon-sm'));
1234
1294
  status.title = runtimeState.statusLabel;
@@ -1236,7 +1296,7 @@ export class DiagramRenderer {
1236
1296
  applyRuntimeTone(status, this.options.runtimeAppearance?.resolveStatus(runtimeState.status));
1237
1297
  if (status instanceof HTMLButtonElement) {
1238
1298
  status.type = 'button';
1239
- status.setAttribute('aria-label', `查看${node.name || def.label}审批详情,当前状态:${runtimeState.statusLabel}`);
1299
+ status.setAttribute('aria-label', this._t('canvas.viewRuntimeDetailsAria', { name: node.name || typeLabel, status: runtimeState.statusLabel }));
1240
1300
  status.addEventListener('click', requestDetails);
1241
1301
  } else {
1242
1302
  status.setAttribute('aria-label', runtimeState.statusLabel);
@@ -1265,7 +1325,7 @@ export class DiagramRenderer {
1265
1325
  titleWrap.appendChild(action);
1266
1326
  }
1267
1327
  } else {
1268
- const title = node.name || def.label;
1328
+ const title = node.name || typeLabel;
1269
1329
  titleWrap.appendChild(el('div', 'mb-node-title', title));
1270
1330
  if (subtitle !== null) titleWrap.appendChild(el('div', 'mb-node-subtitle', subtitle));
1271
1331
  const label = nodeAccessibleLabel(title, subtitle);
@@ -1278,7 +1338,7 @@ export class DiagramRenderer {
1278
1338
  }
1279
1339
 
1280
1340
  _applyDefinitionPresentation({ nodeEl, node, definition, subtitle }) {
1281
- const title = node.name || definition.label;
1341
+ const title = node.name || (node.type ? this.i18n.elementTypeLabel(node.type, definition.label) : definition.label);
1282
1342
  const titleWrap = nodeEl.querySelector('.mb-node-title-wrap');
1283
1343
  const titleEl = titleWrap?.querySelector('.mb-node-title');
1284
1344
  if (!titleWrap || !titleEl) return;
@@ -1355,7 +1415,9 @@ export class DiagramRenderer {
1355
1415
  port.style.bottom = 'auto';
1356
1416
  }
1357
1417
  port.type = 'button';
1358
- port.title = target ? '连接到此节点' : (side === 'right' ? '创建连接' : '输入连接点');
1418
+ port.title = target
1419
+ ? this._t('canvas.ports.connectToNode')
1420
+ : (side === 'right' ? this._t('canvas.ports.createConnection') : this._t('canvas.ports.incomingPort'));
1359
1421
  port.tabIndex = -1;
1360
1422
  port.addEventListener('pointerdown', (event) => {
1361
1423
  event.stopPropagation();
@@ -1397,7 +1459,7 @@ export class DiagramRenderer {
1397
1459
  .sort((a, b) => a.y - b.y || a.id.localeCompare(b.id));
1398
1460
  if (siblings.at(-1)?.id !== node.id) {
1399
1461
  const divider = el('span', 'mb-lane-divider');
1400
- divider.title = '调整相邻泳道高度';
1462
+ divider.title = this._t('canvas.resizeLaneDivider');
1401
1463
  divider.addEventListener('pointerdown', (event) => {
1402
1464
  event.preventDefault();
1403
1465
  event.stopPropagation();
@@ -1425,8 +1487,8 @@ export class DiagramRenderer {
1425
1487
  if (def.kind === 'container' && this.options.onEnterSubProcess) {
1426
1488
  const enter = el('button', 'mb-action-btn mb-action-enter');
1427
1489
  enter.type = 'button';
1428
- enter.title = '进入子流程';
1429
- enter.setAttribute('aria-label', '进入子流程');
1490
+ enter.title = this._t('canvas.nodeActions.enterSubProcess');
1491
+ enter.setAttribute('aria-label', enter.title);
1430
1492
  enter.appendChild(uiIconElement(this.iconRegistry, 'ui.enterScope'));
1431
1493
  enter.addEventListener('pointerdown', (event) => event.stopPropagation());
1432
1494
  enter.addEventListener('click', (event) => {
@@ -1438,8 +1500,8 @@ export class DiagramRenderer {
1438
1500
  if (canOutgoing) {
1439
1501
  const quick = el('button', 'mb-action-btn mb-action-primary');
1440
1502
  quick.type = 'button';
1441
- quick.title = '快捷添加下一节点';
1442
- quick.setAttribute('aria-label', '快捷添加下一节点');
1503
+ quick.title = this._t('canvas.nodeActions.quickAdd');
1504
+ quick.setAttribute('aria-label', quick.title);
1443
1505
  quick.appendChild(uiIconElement(this.iconRegistry, 'ui.add'));
1444
1506
  quick.addEventListener('pointerdown', (event) => event.stopPropagation());
1445
1507
  quick.addEventListener('click', (event) => {
@@ -1451,7 +1513,7 @@ export class DiagramRenderer {
1451
1513
 
1452
1514
  const connect = el('button', `mb-action-btn mb-action-connect${isConnectSource ? ' is-active' : ''}`);
1453
1515
  connect.type = 'button';
1454
- connect.title = isConnectSource ? '取消连接模式(Esc)' : '连接到已有节点';
1516
+ connect.title = this._t(isConnectSource ? 'canvas.nodeActions.cancelConnect' : 'canvas.nodeActions.connectExisting');
1455
1517
  connect.setAttribute('aria-label', connect.title);
1456
1518
  connect.appendChild(uiIconElement(this.iconRegistry, 'ui.connect'));
1457
1519
  connect.setAttribute('aria-pressed', isConnectSource ? 'true' : 'false');
@@ -1465,7 +1527,7 @@ export class DiagramRenderer {
1465
1527
  const isGroup = def.kind === 'group';
1466
1528
  const remove = el('button', 'mb-action-btn mb-action-danger');
1467
1529
  remove.type = 'button';
1468
- remove.title = isGroup ? '取消分组' : '删除节点';
1530
+ remove.title = this._t(isGroup ? 'canvas.nodeActions.ungroup' : 'canvas.nodeActions.deleteNode');
1469
1531
  remove.setAttribute('aria-label', remove.title);
1470
1532
  remove.appendChild(uiIconElement(this.iconRegistry, 'ui.delete'));
1471
1533
  remove.addEventListener('pointerdown', (event) => event.stopPropagation());
@@ -1478,7 +1540,7 @@ export class DiagramRenderer {
1478
1540
  nodeEl.appendChild(actions);
1479
1541
 
1480
1542
  if (isConnectSource) {
1481
- const hint = el('div', 'mb-connect-mode-hint', '选择目标节点 · Esc 取消');
1543
+ const hint = el('div', 'mb-connect-mode-hint', this._t('canvas.connectHint'));
1482
1544
  nodeEl.appendChild(hint);
1483
1545
  }
1484
1546
  }
@@ -1494,19 +1556,19 @@ export class DiagramRenderer {
1494
1556
 
1495
1557
  const head = el('div', 'mb-quick-menu-head');
1496
1558
  const headText = el('div');
1497
- headText.appendChild(el('div', 'mb-quick-menu-title', '添加下一节点'));
1498
- headText.appendChild(el('div', 'mb-quick-menu-subtitle', '自动连线并智能摆放'));
1559
+ headText.appendChild(el('div', 'mb-quick-menu-title', this._t('canvas.quickMenu.title')));
1560
+ headText.appendChild(el('div', 'mb-quick-menu-subtitle', this._t('canvas.quickMenu.subtitle')));
1499
1561
  const close = el('button', 'mb-quick-menu-close');
1500
1562
  close.type = 'button';
1501
- close.title = '关闭';
1502
- close.setAttribute('aria-label', '关闭');
1563
+ close.title = this._t('canvas.quickMenu.close');
1564
+ close.setAttribute('aria-label', close.title);
1503
1565
  close.appendChild(uiIconElement(this.iconRegistry, 'ui.close'));
1504
1566
  close.addEventListener('click', () => { this.quickMenuNodeId = null; this.render(); });
1505
1567
  head.append(headText, close);
1506
1568
  menu.appendChild(head);
1507
1569
 
1508
1570
  const search = el('input', 'mb-quick-menu-search');
1509
- search.placeholder = '搜索 BPMN 节点…';
1571
+ search.placeholder = this._t('canvas.quickMenu.searchPlaceholder');
1510
1572
  menu.appendChild(search);
1511
1573
 
1512
1574
  const body = el('div', 'mb-quick-menu-body');
@@ -1519,14 +1581,27 @@ export class DiagramRenderer {
1519
1581
  PALETTE_GROUPS.find((group) => group.id === 'activities'),
1520
1582
  ].filter(Boolean);
1521
1583
 
1584
+ const divergingLabel = this._t('elementTypes.parallelDiverging');
1585
+ const convergingLabel = this._t('elementTypes.parallelConverging');
1522
1586
  for (const group of groups) {
1523
1587
  const section = el('div', 'mb-quick-menu-section');
1524
1588
  section.dataset.group = group.id;
1525
- section.appendChild(el('div', 'mb-quick-menu-section-title', group.label));
1589
+ section.appendChild(el('div', 'mb-quick-menu-section-title', this._t(`palette.groups.${group.id}`)));
1526
1590
  const grid = el('div', 'mb-quick-menu-grid');
1527
1591
  const quickItems = group.types.flatMap((type) => type === 'parallelGateway'
1528
- ? [PARALLEL_GATEWAY_PRESETS.diverging, PARALLEL_GATEWAY_PRESETS.converging]
1529
- : [{ id: type, label: NODE_DEFINITIONS[type]?.label, iconId: resolveNodeVisual(type, { surface: 'palette' }).iconId, nodeType: type, preset: undefined }]);
1592
+ ? [
1593
+ {
1594
+ ...PARALLEL_GATEWAY_PRESETS.diverging,
1595
+ label: divergingLabel,
1596
+ preset: { ...PARALLEL_GATEWAY_PRESETS.diverging.preset, name: divergingLabel },
1597
+ },
1598
+ {
1599
+ ...PARALLEL_GATEWAY_PRESETS.converging,
1600
+ label: convergingLabel,
1601
+ preset: { ...PARALLEL_GATEWAY_PRESETS.converging.preset, name: convergingLabel },
1602
+ },
1603
+ ]
1604
+ : [{ id: type, label: this.i18n.elementTypeLabel(type, NODE_DEFINITIONS[type]?.label), iconId: resolveNodeVisual(type, { surface: 'palette' }).iconId, nodeType: type, preset: undefined }]);
1530
1605
  for (const quickItem of quickItems) {
1531
1606
  const type = quickItem.nodeType;
1532
1607
  if (type === 'startEvent') continue;
@@ -1,4 +1,31 @@
1
1
  import type { BpmnEdge, BpmnNode, ProcessModel } from '../core/index.js'
2
+ import type { I18nController, NovaI18nOptions } from '../i18n/index.js'
3
+
4
+ export type RuntimeTimeSurface = 'details' | 'transition' | 'timeline' | 'svg'
5
+ export type RuntimeTimeField = 'start' | 'end' | 'occurred' | 'resolved'
6
+ export interface RuntimeTimeFormatContext {
7
+ surface: RuntimeTimeSurface
8
+ field: RuntimeTimeField
9
+ locale: string
10
+ }
11
+ export type RuntimeTimeFormatter = (
12
+ instant: RuntimeInstant,
13
+ context: RuntimeTimeFormatContext,
14
+ ) => string
15
+ export interface RuntimeTimeFormatOptions {
16
+ timeZone?: string
17
+ locale?: string
18
+ dateStyle?: 'full' | 'long' | 'medium' | 'short'
19
+ timeStyle?: 'full' | 'long' | 'medium' | 'short'
20
+ hour12?: boolean
21
+ }
22
+ export interface FormatRuntimeInstantOptions {
23
+ formatRuntimeTime?: RuntimeTimeFormatter | null
24
+ runtimeTimeFormat?: RuntimeTimeFormatOptions | null
25
+ surface?: RuntimeTimeSurface
26
+ field?: RuntimeTimeField
27
+ locale?: string
28
+ }
2
29
 
3
30
  export type ActivityStatus = 'idle' | 'active' | 'completed' | 'failed' | 'cancelled' | 'skipped'
4
31
  export interface RuntimeParticipant { id?: string; name: string; avatarUrl?: string }
@@ -186,18 +213,19 @@ export interface RuntimePresentation {
186
213
  getTransitions(): RuntimeTransitionPresentation[]
187
214
  }
188
215
  export interface RuntimeAppearanceLike {
216
+ i18n?: I18nController
189
217
  resolveStatus(status: string): string
190
218
  resolveAction(action?: { type?: string; explicitLabel?: string; label?: string }): { label: string; iconId: string; tone: string }
191
219
  resolveTransition(transition?: { type?: string }): { tone: string }
192
220
  }
193
221
 
194
222
  export function parseRuntimeInstant(value?: string | null): RuntimeInstant
195
- export function formatRuntimeInstant(value?: string | RuntimeInstant | null): string
223
+ export function formatRuntimeInstant(value?: string | RuntimeInstant | null, options?: FormatRuntimeInstantOptions | null): string
196
224
  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
225
+ export function normalizeRuntime(snapshot?: Partial<ProcessInstanceSnapshot> | null, options?: { diagnostics?: RuntimeDiagnostic[]; model?: ProcessModel | null } & NovaI18nOptions): ProcessInstanceSnapshot
226
+ export function activityState(runtime: ProcessInstanceSnapshot | null | undefined, elementId: string, options?: { diagnostics?: RuntimeDiagnostic[] } & NovaI18nOptions): ActivityVisitState
227
+ export function inspectRuntime(snapshot?: Partial<ProcessInstanceSnapshot> | null, options?: { model?: ProcessModel | null; appearance?: RuntimeAppearanceLike | null } & NovaI18nOptions): { runtime: ProcessInstanceSnapshot; diagnostics: readonly RuntimeDiagnostic[] }
228
+ export function createRuntimePresentation(context: { model: ProcessModel; runtime?: ProcessInstanceSnapshot | null; appearance?: RuntimeAppearanceLike | null; diagnostics?: RuntimeDiagnostic[] } & NovaI18nOptions): RuntimePresentation
201
229
  export function demoRuntime(): ProcessInstanceSnapshot
202
230
 
203
231
  export type RuntimeElement = BpmnNode | BpmnEdge