@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,17 +1,20 @@
1
1
  import type { BpmnNode, ProcessModel } from '../core/index.js'
2
+ import type { I18nController, NovaI18nOptions } from '../i18n/index.js'
2
3
  import type { IconRegistry, NodeVisualResolution } from '../icons/index.js'
3
- import type { NodeRuntimePresentation, ProcessInstanceSnapshot, RuntimeApprovalActionPresentation, RuntimePresentation, RuntimeAssetRef } from '../runtime/index.js'
4
+ import type { NodeRuntimePresentation, ProcessInstanceSnapshot, RuntimeApprovalActionPresentation, RuntimePresentation, RuntimeAssetRef, RuntimeTimeField, RuntimeTimeFormatOptions, RuntimeTimeFormatter } from '../runtime/index.js'
4
5
  import type { NovaResolvedTheme, NovaThemeSnapshot, RuntimeAppearanceOptions, RuntimeAppearanceResolver, ThemeController } from '../theme/index.js'
5
6
  import type { NodeSubtitleResolver } from '../node-presentation/index.js'
6
7
 
7
8
  export type SvgExportTheme = 'current' | NovaResolvedTheme
8
- export interface SvgExportOptions {
9
+ export interface SvgExportOptions extends NovaI18nOptions {
9
10
  theme?: SvgExportTheme
10
11
  transparentBackground?: boolean
11
12
  padding?: number
12
13
  filename?: string
13
14
  title?: string
14
15
  signal?: AbortSignal
16
+ formatRuntimeTime?: RuntimeTimeFormatter | null
17
+ runtimeTimeFormat?: RuntimeTimeFormatOptions | null
15
18
  }
16
19
  export interface SvgExportWarning {
17
20
  code: string
@@ -49,10 +52,12 @@ export type RuntimeTimelineSvgRenderer = (context: {
49
52
  themeSnapshot: NovaThemeSnapshot
50
53
  appearance: RuntimeAppearanceResolver
51
54
  resolveAsset?: SvgRuntimeAssetResolver
55
+ formatTime?: (value?: string | null, field?: RuntimeTimeField) => string
56
+ i18n?: I18nController
52
57
  signal?: AbortSignal
53
58
  }) => void | { height?: number } | Promise<void | { height?: number }>
54
59
  export type SvgRuntimeAssetResolver = (asset: RuntimeAssetRef, purpose: 'export', action: RuntimeApprovalActionPresentation) => string | null | Promise<string | null>
55
- export interface DiagramSvgExportContext {
60
+ export interface DiagramSvgExportContext extends NovaI18nOptions {
56
61
  document?: Document
57
62
  root?: HTMLElement
58
63
  model: ProcessModel
@@ -70,7 +75,7 @@ export interface DiagramSvgExportContext {
70
75
  mode?: 'design' | 'viewer' | 'instance'
71
76
  label?: string
72
77
  }
73
- export interface RuntimeTimelineSvgExportContext {
78
+ export interface RuntimeTimelineSvgExportContext extends NovaI18nOptions {
74
79
  document?: Document
75
80
  root?: HTMLElement
76
81
  model: ProcessModel
@@ -85,6 +90,8 @@ export interface RuntimeTimelineSvgExportContext {
85
90
  resolveAsset?: SvgRuntimeAssetResolver
86
91
  assetCache?: Map<string, string>
87
92
  timelineRenderer?: RuntimeTimelineSvgRenderer
93
+ formatRuntimeTime?: RuntimeTimeFormatter | null
94
+ runtimeTimeFormat?: RuntimeTimeFormatOptions | null
88
95
  label?: string
89
96
  }
90
97
  export function sanitizeSvgFilename(value: string, fallback?: string): string
@@ -92,7 +99,7 @@ export function exportDiagramSvg(context: DiagramSvgExportContext, options?: Svg
92
99
  export function exportRuntimeTimelineSvg(context: RuntimeTimelineSvgExportContext, options?: SvgExportOptions & { width?: number; description?: string }): Promise<SvgExportArtifact>
93
100
  export function downloadSvg(artifact: SvgExportArtifact, options?: { document?: Document }): string
94
101
 
95
- export interface SvgExportPreviewOptions {
102
+ export interface SvgExportPreviewOptions extends NovaI18nOptions {
96
103
  container: HTMLElement
97
104
  createArtifact(options: SvgExportOptions): Promise<SvgExportArtifact>
98
105
  title?: string
@@ -1,3 +1,4 @@
1
+ import { resolveI18n } from '../i18n/index.js';
1
2
  import { downloadSvg } from './render.js';
2
3
 
3
4
  function element(document, tag, className = '', text = '') {
@@ -18,12 +19,13 @@ function clamp(value, min, max) {
18
19
  }
19
20
 
20
21
  export class SvgExportPreviewController {
21
- constructor({ container, createArtifact, title = '导出 SVG', initialTheme = 'current', onClose = null, onDownload = null } = {}) {
22
+ constructor({ container, createArtifact, title, initialTheme = 'current', onClose = null, onDownload = null, i18n = null, locale, messages } = {}) {
22
23
  if (!container) throw new Error('SVG export preview requires a container.');
23
24
  if (typeof createArtifact !== 'function') throw new Error('SVG export preview requires createArtifact().');
24
25
  this.container = container;
25
26
  this.document = container.ownerDocument;
26
27
  this.ownerWindow = this.document.defaultView || globalThis;
28
+ this.i18n = resolveI18n({ i18n, locale, messages });
27
29
  this.createArtifact = createArtifact;
28
30
  this.onClose = onClose;
29
31
  this.onDownload = onDownload;
@@ -37,11 +39,15 @@ export class SvgExportPreviewController {
37
39
  this.drag = null;
38
40
  this.closed = false;
39
41
  this._restoreFocus = this.document.activeElement instanceof this.ownerWindow.HTMLElement ? this.document.activeElement : null;
40
- this._build(title);
42
+ this._build(title || this.i18n.t('exportSvg.preview.defaultTitle'));
41
43
  this._bind();
42
44
  this._generate();
43
45
  }
44
46
 
47
+ _t(key, params) {
48
+ return this.i18n.t(key, params);
49
+ }
50
+
45
51
  _build(title) {
46
52
  const document = this.document;
47
53
  const root = element(document, 'div', 'nova-svg-export-preview is-entering');
@@ -51,17 +57,21 @@ export class SvgExportPreviewController {
51
57
  const dialog = element(document, 'section', 'nova-svg-export-dialog');
52
58
  const header = element(document, 'header', 'nova-svg-export-header');
53
59
  const heading = element(document, 'div', 'nova-svg-export-heading');
54
- heading.append(element(document, 'strong', '', title), element(document, 'span', '', '预览确认后下载'));
60
+ heading.append(element(document, 'strong', '', title), element(document, 'span', '', this._t('exportSvg.preview.subtitle')));
55
61
  const close = button(document, '×', 'nova-svg-export-close');
56
- close.setAttribute('aria-label', '关闭 SVG 预览');
62
+ close.setAttribute('aria-label', this._t('exportSvg.preview.closeAria'));
57
63
  header.append(heading, close);
58
64
 
59
65
  const toolbar = element(document, 'div', 'nova-svg-export-toolbar');
60
66
  const themeGroup = element(document, 'div', 'nova-svg-export-theme');
61
67
  themeGroup.setAttribute('role', 'group');
62
- themeGroup.setAttribute('aria-label', 'SVG 主题');
68
+ themeGroup.setAttribute('aria-label', this._t('exportSvg.preview.themeGroupAria'));
63
69
  this.themeButtons = new Map();
64
- for (const option of [{ value: 'current', label: '当前' }, { value: 'light', label: '浅色' }, { value: 'dark', label: '深色' }]) {
70
+ for (const option of [
71
+ { value: 'current', label: this._t('exportSvg.preview.themeCurrent') },
72
+ { value: 'light', label: this._t('exportSvg.preview.themeLight') },
73
+ { value: 'dark', label: this._t('exportSvg.preview.themeDark') },
74
+ ]) {
65
75
  const item = button(document, option.label);
66
76
  item.dataset.exportTheme = option.value;
67
77
  item.addEventListener('click', () => this.setTheme(option.value));
@@ -72,14 +82,14 @@ export class SvgExportPreviewController {
72
82
  const transparent = element(document, 'input');
73
83
  transparent.type = 'checkbox';
74
84
  transparent.addEventListener('change', () => this.setTransparentBackground(transparent.checked));
75
- transparentLabel.append(transparent, document.createTextNode('透明背景'));
85
+ transparentLabel.append(transparent, document.createTextNode(this._t('exportSvg.preview.transparentBackground')));
76
86
  const viewportTools = element(document, 'div', 'nova-svg-export-viewport-tools');
77
87
  const zoomOut = button(document, '−');
78
- zoomOut.title = '缩小';
79
- const fit = button(document, '最佳视图');
80
- const actual = button(document, '1:1');
88
+ zoomOut.title = this._t('exportSvg.preview.zoomOut');
89
+ const fit = button(document, this._t('exportSvg.preview.fitView'));
90
+ const actual = button(document, this._t('exportSvg.preview.actualSize'));
81
91
  const zoomIn = button(document, '+');
82
- zoomIn.title = '放大';
92
+ zoomIn.title = this._t('exportSvg.preview.zoomIn');
83
93
  this.zoomText = element(document, 'span', '', '100%');
84
94
  viewportTools.append(zoomOut, this.zoomText, zoomIn, fit, actual);
85
95
  toolbar.append(themeGroup, transparentLabel, viewportTools);
@@ -87,25 +97,25 @@ export class SvgExportPreviewController {
87
97
  const body = element(document, 'div', 'nova-svg-export-body');
88
98
  const viewport = element(document, 'div', 'nova-svg-export-viewport');
89
99
  viewport.tabIndex = 0;
90
- viewport.setAttribute('aria-label', 'SVG 预览画布,可拖动和缩放');
100
+ viewport.setAttribute('aria-label', this._t('exportSvg.preview.viewportAria'));
91
101
  const stage = element(document, 'div', 'nova-svg-export-stage');
92
102
  const image = element(document, 'img', 'nova-svg-export-image');
93
- image.alt = 'SVG 导出预览';
103
+ image.alt = this._t('exportSvg.preview.imageAlt');
94
104
  stage.appendChild(image);
95
105
  viewport.appendChild(stage);
96
106
  const state = element(document, 'div', 'nova-svg-export-state');
97
- state.append(element(document, 'span', 'nova-svg-export-spinner'), element(document, 'strong', '', '正在生成 SVG…'));
107
+ state.append(element(document, 'span', 'nova-svg-export-spinner'), element(document, 'strong', '', this._t('exportSvg.preview.generating')));
98
108
  body.append(viewport, state);
99
109
 
100
110
  const warning = element(document, 'div', 'nova-svg-export-warnings');
101
111
  warning.hidden = true;
102
112
  const footer = element(document, 'footer', 'nova-svg-export-footer');
103
- const summary = element(document, 'span', 'nova-svg-export-summary', '准备导出');
113
+ const summary = element(document, 'span', 'nova-svg-export-summary', this._t('exportSvg.preview.preparingExport'));
104
114
  const actions = element(document, 'div', 'nova-svg-export-actions');
105
- const cancel = button(document, '取消');
106
- const retry = button(document, '重试', 'nova-svg-export-retry');
115
+ const cancel = button(document, this._t('exportSvg.preview.cancel'));
116
+ const retry = button(document, this._t('exportSvg.preview.retry'), 'nova-svg-export-retry');
107
117
  retry.hidden = true;
108
- const confirm = button(document, '确认下载', 'is-primary');
118
+ const confirm = button(document, this._t('exportSvg.preview.confirmDownload'), 'is-primary');
109
119
  confirm.disabled = true;
110
120
  actions.append(cancel, retry, confirm);
111
121
  footer.append(summary, actions);
@@ -200,8 +210,8 @@ export class SvgExportPreviewController {
200
210
  this.root.classList.add('is-loading');
201
211
  this.state.hidden = false;
202
212
  this.state.classList.remove('is-error');
203
- this.state.querySelector('strong').textContent = '正在生成 SVG…';
204
- this.summary.textContent = '正在准备完整内容';
213
+ this.state.querySelector('strong').textContent = this._t('exportSvg.preview.generating');
214
+ this.summary.textContent = this._t('exportSvg.preview.preparingFullContent');
205
215
  this._revokePreviewUrl();
206
216
  this.image.removeAttribute('src');
207
217
  try {
@@ -224,8 +234,8 @@ export class SvgExportPreviewController {
224
234
  this.root.classList.remove('is-loading');
225
235
  this.state.hidden = false;
226
236
  this.state.classList.add('is-error');
227
- this.state.querySelector('strong').textContent = `生成失败:${error?.message || '未知错误'}`;
228
- this.summary.textContent = 'SVG 尚未生成';
237
+ this.state.querySelector('strong').textContent = this._t('exportSvg.preview.failed', { message: error?.message || this._t('exportSvg.preview.unknownError') });
238
+ this.summary.textContent = this._t('exportSvg.preview.notGenerated');
229
239
  this.retryButton.hidden = false;
230
240
  }
231
241
  }
@@ -234,10 +244,10 @@ export class SvgExportPreviewController {
234
244
  this.warning.replaceChildren();
235
245
  if (!warnings.length) { this.warning.hidden = true; return; }
236
246
  this.warning.hidden = false;
237
- this.warning.appendChild(element(this.document, 'strong', '', `${warnings.length} 项内容已降级处理`));
247
+ this.warning.appendChild(element(this.document, 'strong', '', this._t('exportSvg.preview.warningsHeading', { count: warnings.length })));
238
248
  const list = element(this.document, 'ul');
239
249
  warnings.slice(0, 5).forEach((item) => list.appendChild(element(this.document, 'li', '', item.message)));
240
- if (warnings.length > 5) list.appendChild(element(this.document, 'li', '', `另有 ${warnings.length - 5} 项`));
250
+ if (warnings.length > 5) list.appendChild(element(this.document, 'li', '', this._t('exportSvg.preview.warningsMore', { count: warnings.length - 5 })));
241
251
  this.warning.appendChild(list);
242
252
  }
243
253
 
@@ -1,4 +1,5 @@
1
1
  import { NODE_DEFINITIONS, edgeWaypoints, roundedPath, routeRuntimeTransition, smoothPath } from '../core/index.js';
2
+ import { DEFAULT_I18N, resolveI18n } from '../i18n/index.js';
2
3
  import { createDefaultIconRegistry, resolveNodeVisual } from '../icons/index.js';
3
4
  import { resolveNodeSubtitle, supportsNodeSubtitle } from '../node-presentation/index.js';
4
5
  import { resolveNodeGeometry, resolvePresentationWaypoints } from '../node-geometry/index.js';
@@ -169,8 +170,21 @@ function finite(value, fallback = 0) {
169
170
  return Number.isFinite(number) ? number : fallback;
170
171
  }
171
172
 
172
- function formatTime(value) {
173
- return formatRuntimeInstant(value);
173
+ function formatTime(value, field = 'occurred', timeConfig = null) {
174
+ return formatRuntimeInstant(value, timeConfig ? {
175
+ formatRuntimeTime: timeConfig.formatRuntimeTime,
176
+ runtimeTimeFormat: timeConfig.runtimeTimeFormat,
177
+ surface: 'svg',
178
+ field,
179
+ locale: timeConfig.locale,
180
+ } : null);
181
+ }
182
+
183
+ function resolveExportI18n(context = {}, options = {}) {
184
+ if (options?.i18n || options?.locale !== undefined || options?.messages !== undefined) return resolveI18n(options);
185
+ if (context?.i18n || context?.locale !== undefined || context?.messages !== undefined) return resolveI18n(context);
186
+ if (context?.runtimeAppearance?.i18n) return resolveI18n(context.runtimeAppearance.i18n);
187
+ return DEFAULT_I18N;
174
188
  }
175
189
 
176
190
  function formatSize(value) {
@@ -330,18 +344,19 @@ function renderGeometryShape(document, group, geometry, fill, stroke) {
330
344
  group.appendChild(shape);
331
345
  }
332
346
 
333
- function renderDefaultNode({ document, group, node, definition, geometry, visual, presentation, subtitle: definitionSubtitle, theme, iconRegistry }) {
347
+ function renderDefaultNode({ document, group, node, definition, geometry, visual, presentation, subtitle: definitionSubtitle, theme, iconRegistry, i18n = DEFAULT_I18N }) {
334
348
  const colors = theme.colors;
335
349
  const statusTone = tone(theme, presentation?.status === 'rejected' ? 'danger' : presentation?.status === 'active' ? 'primary' : presentation?.status === 'completed' ? 'success' : 'neutral');
336
350
  const typeTone = tone(theme, nodeToneName(node));
337
351
  const icon = iconRegistry.resolve(visual.iconId, null);
352
+ const typeLabel = node.type ? i18n.elementTypeLabel(node.type, definition.label) : definition.label;
338
353
  const { x, y, width, height } = node;
339
354
  if (['event', 'boundary'].includes(definition.kind)) {
340
355
  const radius = Math.min(width, height) / 2 - 2;
341
356
  group.appendChild(svgElement(document, 'circle', { cx: x + width / 2, cy: y + height / 2, r: radius, fill: colors.surface, stroke: presentation?.status && presentation.status !== 'idle' ? statusTone.strong : colors.borderStrong, 'stroke-width': definition.eventStage === 'end' ? 3 : 2, 'stroke-dasharray': definition.kind === 'boundary' && node.properties?.cancelActivity === false ? '5 3' : null }));
342
357
  if (definition.eventStage === 'intermediate' || definition.kind === 'boundary') group.appendChild(svgElement(document, 'circle', { cx: x + width / 2, cy: y + height / 2, r: radius - 5, fill: 'none', stroke: colors.borderStrong, 'stroke-width': 1.4 }));
343
358
  appendIcon(document, group, icon, { x: x + width * 0.3, y: y + height * 0.3, width: width * 0.4, height: height * 0.4 }, colors.textSecondary);
344
- appendTextLines(document, group, wrapText(node.name || definition.label, 150, 12), { x: x + width / 2, y: y + height + 20, lineHeight: 15, attributes: { 'text-anchor': 'middle', fill: colors.textSecondary, 'font-size': 12, 'font-family': theme.fontFamily } });
359
+ appendTextLines(document, group, wrapText(node.name || typeLabel, 150, 12), { x: x + width / 2, y: y + height + 20, lineHeight: 15, attributes: { 'text-anchor': 'middle', fill: colors.textSecondary, 'font-size': 12, 'font-family': theme.fontFamily } });
345
360
  return;
346
361
  }
347
362
  if (['gateway', 'data', 'dataStore'].includes(definition.kind)) {
@@ -349,25 +364,25 @@ function renderDefaultNode({ document, group, node, definition, geometry, visual
349
364
  const stroke = definition.kind === 'gateway' && presentation?.status && presentation.status !== 'idle' ? statusTone.strong : colors.borderStrong;
350
365
  renderGeometryShape(document, group, geometry, colors.surface, stroke);
351
366
  appendIcon(document, group, icon, geometry.iconBounds, colors.textSecondary);
352
- appendTextLines(document, group, wrapText(node.name || definition.label, definition.kind === 'gateway' ? 160 : 150, 12), { x: geometry.label.x, y: geometry.label.y + 12, lineHeight: geometry.label.lineHeight, attributes: { 'text-anchor': 'middle', fill: colors.textSecondary, 'font-size': 12, 'font-family': theme.fontFamily } });
367
+ appendTextLines(document, group, wrapText(node.name || typeLabel, definition.kind === 'gateway' ? 160 : 150, 12), { x: geometry.label.x, y: geometry.label.y + 12, lineHeight: geometry.label.lineHeight, attributes: { 'text-anchor': 'middle', fill: colors.textSecondary, 'font-size': 12, 'font-family': theme.fontFamily } });
353
368
  return;
354
369
  }
355
370
  if (definition.kind === 'participant' || definition.kind === 'lane') {
356
371
  group.appendChild(svgElement(document, 'rect', { x, y, width, height, rx: 4, fill: colors.surfaceSubtle, stroke: colors.borderStrong, 'stroke-width': 1.3 }));
357
372
  const rail = Math.min(42, Math.max(30, width * 0.08));
358
373
  group.appendChild(svgElement(document, 'line', { x1: x + rail, y1: y, x2: x + rail, y2: y + height, stroke: colors.borderStrong, 'stroke-width': 1.2 }));
359
- const title = svgElement(document, 'text', { x: x + rail / 2, y: y + height / 2, transform: `rotate(-90 ${x + rail / 2} ${y + height / 2})`, 'text-anchor': 'middle', fill: colors.textSecondary, 'font-size': 12, 'font-weight': 600, 'font-family': theme.fontFamily }, node.name || definition.label);
374
+ const title = svgElement(document, 'text', { x: x + rail / 2, y: y + height / 2, transform: `rotate(-90 ${x + rail / 2} ${y + height / 2})`, 'text-anchor': 'middle', fill: colors.textSecondary, 'font-size': 12, 'font-weight': 600, 'font-family': theme.fontFamily }, node.name || typeLabel);
360
375
  group.appendChild(title);
361
376
  return;
362
377
  }
363
378
  if (definition.kind === 'group') {
364
379
  group.appendChild(svgElement(document, 'rect', { x, y, width, height, rx: 10, fill: 'none', stroke: colors.borderStrong, 'stroke-width': 1.2, 'stroke-dasharray': '7 5' }));
365
- group.appendChild(svgElement(document, 'text', { x: x + 12, y: y + 22, fill: colors.textSecondary, 'font-size': 12, 'font-weight': 600, 'font-family': theme.fontFamily }, node.properties?.categoryValue || node.name || '分组'));
380
+ group.appendChild(svgElement(document, 'text', { x: x + 12, y: y + 22, fill: colors.textSecondary, 'font-size': 12, 'font-weight': 600, 'font-family': theme.fontFamily }, node.properties?.categoryValue || node.name || i18n.t('canvas.defaultGroupCaption')));
366
381
  return;
367
382
  }
368
383
  if (definition.kind === 'annotation') {
369
384
  group.appendChild(svgElement(document, 'path', { d: `M ${x + 10} ${y} H ${x} V ${y + height} H ${x + 10}`, fill: 'none', stroke: colors.borderStrong, 'stroke-width': 1.5 }));
370
- appendTextLines(document, group, wrapText(node.properties?.text || node.name || '说明', width - 24, 12), { x: x + 16, y: y + 20, lineHeight: 17, attributes: { fill: colors.textSecondary, 'font-size': 12, 'font-family': theme.fontFamily } });
385
+ appendTextLines(document, group, wrapText(node.properties?.text || node.name || i18n.t('canvas.defaultAnnotationCaption'), width - 24, 12), { x: x + 16, y: y + 20, lineHeight: 17, attributes: { fill: colors.textSecondary, 'font-size': 12, 'font-family': theme.fontFamily } });
371
386
  return;
372
387
  }
373
388
 
@@ -375,7 +390,7 @@ function renderDefaultNode({ document, group, node, definition, geometry, visual
375
390
  const iconX = x + 14;
376
391
  const iconY = y + (height - iconSize) / 2;
377
392
  const copyX = iconX + iconSize + 12;
378
- const title = node.name || definition.label;
393
+ const title = node.name || typeLabel;
379
394
  const subtitle = definitionSubtitle === undefined
380
395
  ? presentation?.actionSummary || presentation?.summary || (node.properties?.assignee || node.properties?.candidateGroups || node.properties?.candidateUsers || '')
381
396
  : definitionSubtitle;
@@ -416,7 +431,7 @@ function renderDefaultNode({ document, group, node, definition, geometry, visual
416
431
  }
417
432
  }
418
433
 
419
- function prepareNodes({ document, context, options, model, presentation, theme, iconRegistry, warnings }) {
434
+ function prepareNodes({ document, context, options, model, presentation, theme, iconRegistry, warnings, i18n }) {
420
435
  const nodeLayer = svgElement(document, 'g', { 'data-layer': 'nodes' });
421
436
  const geometries = new Map();
422
437
  const runtimeMode = context.mode === 'instance' || Boolean(context.runtime);
@@ -437,18 +452,18 @@ function prepareNodes({ document, context, options, model, presentation, theme,
437
452
  if (!rendered) group.replaceChildren();
438
453
  } catch (error) {
439
454
  group.replaceChildren();
440
- warnings.push({ code: 'custom-node-renderer-failed', message: `节点“${node.name || node.id}”的 SVG Renderer 执行失败,已使用标准视觉。`, elementId: node.id });
455
+ warnings.push({ code: 'custom-node-renderer-failed', message: i18n.t('exportSvg.warnings.customNodeRendererFailed', { name: node.name || node.id }), elementId: node.id });
441
456
  }
442
457
  } else if (context.htmlNodeRenderers?.[node.type] || context.htmlNodeRenderers?.[definition.kind] || context.htmlNodeRenderer) {
443
- warnings.push({ code: 'custom-node-renderer-fallback', message: `节点“${node.name || node.id}”没有 SVG Renderer,已使用标准视觉。`, elementId: node.id });
458
+ warnings.push({ code: 'custom-node-renderer-fallback', message: i18n.t('exportSvg.warnings.customNodeRendererFallback', { name: node.name || node.id }), elementId: node.id });
444
459
  }
445
460
  if (!rendered) {
446
461
  const geometry = resolveNodeGeometry(node, definition);
447
462
  geometries.set(node.id, geometry);
448
463
  const subtitle = !runtimeMode && supportsNodeSubtitle(definition)
449
- ? resolveNodeSubtitle({ node, definition, model, mode: definitionMode, surface: 'svg-export', resolver: context.nodeSubtitleResolver })
464
+ ? resolveNodeSubtitle({ node, definition, model, mode: definitionMode, surface: 'svg-export', resolver: context.nodeSubtitleResolver, i18n })
450
465
  : undefined;
451
- renderDefaultNode({ document, group, node, definition, geometry, visual, presentation: nodePresentation, subtitle, theme, iconRegistry });
466
+ renderDefaultNode({ document, group, node, definition, geometry, visual, presentation: nodePresentation, subtitle, theme, iconRegistry, i18n });
452
467
  }
453
468
  nodeLayer.appendChild(group);
454
469
  }
@@ -458,10 +473,11 @@ function prepareNodes({ document, context, options, model, presentation, theme,
458
473
  export async function exportDiagramSvg(context = {}, options = {}) {
459
474
  options.signal?.throwIfAborted?.();
460
475
  const document = resolvedDocument(context);
476
+ const i18n = resolveExportI18n(context, options);
461
477
  const model = context.model || { id: 'Process', name: 'BPMN Nova', nodes: [], edges: [], settings: {} };
462
478
  const theme = themeSnapshot(context, options);
463
- const appearance = context.runtimeAppearance?.resolveStatus ? context.runtimeAppearance : createRuntimeAppearance(context.runtimeAppearance || {});
464
- const presentation = context.runtimePresentation || createRuntimePresentation({ model, runtime: context.runtime || null, appearance });
479
+ const appearance = context.runtimeAppearance?.resolveStatus ? context.runtimeAppearance : createRuntimeAppearance(context.runtimeAppearance || {}, { i18n });
480
+ const presentation = context.runtimePresentation || createRuntimePresentation({ model, runtime: context.runtime || null, appearance, i18n });
465
481
  const iconRegistry = context.iconRegistry || createDefaultIconRegistry();
466
482
  const warnings = [];
467
483
  const bounds = { left: Infinity, top: Infinity, right: -Infinity, bottom: -Infinity };
@@ -490,7 +506,7 @@ export async function exportDiagramSvg(context = {}, options = {}) {
490
506
  addDefinitions(document, svg, theme);
491
507
 
492
508
  // Resolve custom renderers once before docking edges, without changing the final layer order.
493
- const { nodeLayer, geometries } = prepareNodes({ document, context, options, model, presentation, theme, iconRegistry, warnings });
509
+ const { nodeLayer, geometries } = prepareNodes({ document, context, options, model, presentation, theme, iconRegistry, warnings, i18n });
494
510
 
495
511
  const edgeLayer = svgElement(document, 'g', { 'data-layer': 'edges' });
496
512
  for (const edge of model.edges || []) {
@@ -534,7 +550,7 @@ export async function exportDiagramSvg(context = {}, options = {}) {
534
550
  const transitionTone = tone(theme, toneName);
535
551
  const markerTone = Object.hasOwn(theme.tones || {}, toneName) && /^[a-z][a-z0-9-]{0,47}$/.test(toneName) ? toneName : 'neutral';
536
552
  transitionLayer.appendChild(svgElement(document, 'path', { d: routePath(display.points, model.settings?.edgeStyle || 'rounded', model.settings?.cornerRadius || 14), fill: 'none', stroke: transitionTone.strong, 'stroke-width': 2.2, 'stroke-dasharray': '8 6', 'stroke-linecap': 'round', 'stroke-linejoin': 'round', 'marker-end': `url(#nova-arrow-${markerTone}${display.targetDocked ? '-docked' : ''})`, opacity: transition.latest ? 1 : 0.42 }));
537
- const label = transition.label || (transition.type === 'reject' ? '驳回' : '退回');
553
+ const label = transition.label || i18n.t(transition.type === 'reject' ? 'runtime.transitions.reject' : 'runtime.transitions.return');
538
554
  const labelTypography = { fontSize: 11, fontWeight: 650, fontFamily: theme.fontFamily };
539
555
  const labelWidth = Math.max(68, Math.min(210, Math.ceil(measureText(document, label, labelTypography) + 20)));
540
556
  const fittedLabel = fitText(document, label, labelWidth - 16, labelTypography);
@@ -548,11 +564,12 @@ export async function exportDiagramSvg(context = {}, options = {}) {
548
564
  }
549
565
 
550
566
  svg.appendChild(nodeLayer);
551
- const filename = sanitizeSvgFilename(options.filename || `${model.name || model.id || 'process'}-${context.label || (context.mode === 'instance' ? '审批轨迹' : context.mode === 'viewer' ? '流程展示' : '流程设计')}`);
567
+ const defaultLabel = i18n.t(context.mode === 'instance' ? 'exportSvg.defaultLabels.instance' : context.mode === 'viewer' ? 'exportSvg.defaultLabels.viewer' : 'exportSvg.defaultLabels.design');
568
+ const filename = sanitizeSvgFilename(options.filename || `${model.name || model.id || 'process'}-${context.label || defaultLabel}`);
552
569
  return serializeArtifact(document, svg, { filename, width, height, viewBox: { x: minX, y: minY, width, height }, warnings });
553
570
  }
554
571
 
555
- async function resolvedImageData(asset, action, context, warnings, signal) {
572
+ async function resolvedImageData(asset, action, context, warnings, signal, i18n = DEFAULT_I18N) {
556
573
  const cache = context.assetCache || new Map();
557
574
  const key = `${asset.id}:export`;
558
575
  const cached = cache.get(key);
@@ -583,7 +600,7 @@ async function resolvedImageData(asset, action, context, warnings, signal) {
583
600
  } catch (error) {
584
601
  cache.delete(key);
585
602
  if (signal?.aborted) throw error;
586
- warnings.push({ code: 'asset-unavailable', message: `图片“${asset.name}”无法嵌入 SVG,已显示占位内容。`, assetId: asset.id, elementId: action.elementId });
603
+ warnings.push({ code: 'asset-unavailable', message: i18n.t('exportSvg.warnings.assetUnavailable', { name: asset.name }), assetId: asset.id, elementId: action.elementId });
587
604
  return null;
588
605
  }
589
606
  }
@@ -602,7 +619,7 @@ function participantInitial(participant) {
602
619
  return String(participant?.name || '').trim().slice(0, 1) || '?';
603
620
  }
604
621
 
605
- async function resolvedAvatarData(url, context, warnings, signal, item) {
622
+ async function resolvedAvatarData(url, context, warnings, signal, item, i18n = DEFAULT_I18N) {
606
623
  const source = String(url || '').trim();
607
624
  if (!source) return null;
608
625
  const cache = context.avatarCache || (context.avatarCache = new Map());
@@ -630,12 +647,12 @@ async function resolvedAvatarData(url, context, warnings, signal, item) {
630
647
  } catch (error) {
631
648
  cache.delete(source);
632
649
  if (signal?.aborted) throw error;
633
- warnings.push({ code: 'avatar-unavailable', message: '处理人头像无法嵌入 SVG,已显示姓名首字。', elementId: item?.elementId });
650
+ warnings.push({ code: 'avatar-unavailable', message: i18n.t('exportSvg.warnings.avatarUnavailable'), elementId: item?.elementId });
634
651
  return null;
635
652
  }
636
653
  }
637
654
 
638
- async function renderTimelineAvatars({ document, parent, people, x, y, theme, context, warnings, signal, item }) {
655
+ async function renderTimelineAvatars({ document, parent, people, x, y, theme, context, warnings, signal, item, i18n = DEFAULT_I18N }) {
639
656
  const visible = people.slice(0, AVATAR_VISIBLE_LIMIT);
640
657
  const overflow = people.length - AVATAR_VISIBLE_LIMIT;
641
658
  const count = visible.length + (overflow > 0 ? 1 : 0);
@@ -645,7 +662,7 @@ async function renderTimelineAvatars({ document, parent, people, x, y, theme, co
645
662
  const cx = left + AVATAR_SIZE / 2;
646
663
  const cy = y + AVATAR_SIZE / 2;
647
664
  const person = visible[index];
648
- const data = await resolvedAvatarData(person.avatarUrl, context, warnings, signal, item);
665
+ const data = await resolvedAvatarData(person.avatarUrl, context, warnings, signal, item, i18n);
649
666
  parent.appendChild(svgElement(document, 'circle', {
650
667
  cx, cy, r: AVATAR_SIZE / 2, fill: theme.colors.primarySoft, stroke: theme.colors.surface, 'stroke-width': 2,
651
668
  }));
@@ -694,18 +711,19 @@ function actionHeight(action) {
694
711
  return 52 + targets + Math.max(1, blockParagraphs || paragraphLines) * 17 + (images ? 68 : 0) + files * 40;
695
712
  }
696
713
 
697
- async function renderTimelineAction({ document, parent, action, x, y, width, theme, appearance, context, warnings, signal }) {
714
+ async function renderTimelineAction({ document, parent, action, x, y, width, theme, appearance, context, warnings, signal, i18n = DEFAULT_I18N, timeConfig = null }) {
698
715
  const actionAppearance = appearance.resolveAction(action);
699
716
  const actionTone = tone(theme, actionAppearance.tone);
700
717
  const height = actionHeight(action);
701
718
  parent.appendChild(svgElement(document, 'rect', { x, y, width, height, rx: 9, fill: theme.colors.surfaceSubtle }));
702
- const labelWidth = Math.max(42, Math.min(86, Array.from(actionAppearance.label).length * 12 + 16));
719
+ const labelTypography = { fontSize: 11, fontWeight: 650, fontFamily: theme.fontFamily };
720
+ const labelWidth = Math.max(42, Math.min(132, Math.ceil(measureText(document, actionAppearance.label, labelTypography) + 20)));
703
721
  parent.appendChild(svgElement(document, 'rect', { x: x + 12, y: y + 10, width: labelWidth, height: 22, rx: 11, fill: actionTone.background }));
704
722
  parent.appendChild(svgElement(document, 'text', { x: x + 12 + labelWidth / 2, y: y + 25, 'text-anchor': 'middle', fill: actionTone.foreground, 'font-size': 11, 'font-weight': 650, 'font-family': theme.fontFamily }, actionAppearance.label));
705
- parent.appendChild(svgElement(document, 'text', { x: x + 22 + labelWidth, y: y + 25, fill: theme.colors.textMuted, 'font-size': 11, 'font-family': theme.fontFamily }, [action.actor?.name, formatTime(action.occurredAt)].filter(Boolean).join(' · ')));
723
+ parent.appendChild(svgElement(document, 'text', { x: x + 22 + labelWidth, y: y + 25, fill: theme.colors.textMuted, 'font-size': 11, 'font-family': theme.fontFamily }, [action.actor?.name, formatTime(action.occurredAt, 'occurred', timeConfig)].filter(Boolean).join(' · ')));
706
724
  let cursorY = y + 48;
707
725
  if (action.targets?.length) {
708
- parent.appendChild(svgElement(document, 'text', { x: x + 12, y: cursorY, fill: theme.colors.textSecondary, 'font-size': 11, 'font-family': theme.fontFamily }, `目标:${action.targets.map((item) => item.name).join('、')}`));
726
+ parent.appendChild(svgElement(document, 'text', { x: x + 12, y: cursorY, fill: theme.colors.textSecondary, 'font-size': 11, 'font-family': theme.fontFamily }, i18n.t('timeline.targets', { names: action.targets.map((item) => item.name).join(i18n.t('common.listSeparator')) })));
709
727
  cursorY += 18;
710
728
  }
711
729
  const paragraphBlocks = (action.content?.blocks || []).filter((block) => block.type === 'paragraph' && block.text);
@@ -723,10 +741,10 @@ async function renderTimelineAction({ document, parent, action, x, y, width, the
723
741
  for (const block of imageBlocks) {
724
742
  const asset = assets.get(block.assetId);
725
743
  if (!asset || !asset.mediaType?.startsWith('image/')) {
726
- warnings.push({ code: 'asset-invalid', message: '审批图片引用无效,已显示占位内容。', assetId: block.assetId, elementId: action.elementId });
744
+ warnings.push({ code: 'asset-invalid', message: i18n.t('exportSvg.warnings.assetInvalid'), assetId: block.assetId, elementId: action.elementId });
727
745
  parent.appendChild(svgElement(document, 'rect', { x: mediaX, y: cursorY, width: 88, height: 58, rx: 7, fill: theme.colors.surfaceMuted, stroke: theme.colors.border }));
728
746
  } else {
729
- const data = await resolvedImageData(asset, action, context, warnings, signal);
747
+ const data = await resolvedImageData(asset, action, context, warnings, signal, i18n);
730
748
  if (data) parent.appendChild(svgElement(document, 'image', { x: mediaX, y: cursorY, width: 88, height: 58, preserveAspectRatio: 'xMidYMid slice', href: data }));
731
749
  else parent.appendChild(svgElement(document, 'rect', { x: mediaX, y: cursorY, width: 88, height: 58, rx: 7, fill: theme.colors.surfaceMuted, stroke: theme.colors.border }));
732
750
  }
@@ -737,18 +755,34 @@ async function renderTimelineAction({ document, parent, action, x, y, width, the
737
755
  const asset = assets.get(block.assetId);
738
756
  const fileY = cursorY;
739
757
  parent.appendChild(svgElement(document, 'rect', { x: x + 12, y: fileY, width: width - 24, height: 34, rx: 7, fill: theme.colors.surfaceRaised, stroke: theme.colors.border }));
740
- parent.appendChild(svgElement(document, 'text', { x: x + 22, y: fileY + 15, fill: theme.colors.textSecondary, 'font-size': 11, 'font-weight': 600, 'font-family': theme.fontFamily }, asset?.name || '附件不可用'));
758
+ parent.appendChild(svgElement(document, 'text', { x: x + 22, y: fileY + 15, fill: theme.colors.textSecondary, 'font-size': 11, 'font-weight': 600, 'font-family': theme.fontFamily }, asset?.name || i18n.t('exportSvg.fileUnavailable')));
741
759
  parent.appendChild(svgElement(document, 'text', { x: x + 22, y: fileY + 28, fill: theme.colors.textMuted, 'font-size': 9.5, 'font-family': theme.fontFamily }, asset ? [asset.mediaType, formatSize(asset.size)].filter(Boolean).join(' · ') : ''));
742
760
  cursorY += 40;
743
761
  }
744
762
  return height;
745
763
  }
746
764
 
747
- function resultLabel(item) {
748
- return ({ approved: '已同意', rejected: '已驳回', returned: '已退回', submitted: '已提交', pending: '待处理' })[item.outcome] || item.statusLabel || '';
765
+ const TIMELINE_RESULT_KEYS = Object.freeze({
766
+ approved: 'timeline.results.approved',
767
+ rejected: 'timeline.results.rejected',
768
+ returned: 'timeline.results.returned',
769
+ submitted: 'timeline.results.submitted',
770
+ pending: 'timeline.results.pending',
771
+ });
772
+
773
+ function resultLabel(item, i18n = DEFAULT_I18N) {
774
+ const key = TIMELINE_RESULT_KEYS[item.outcome];
775
+ return (key ? i18n.t(key) : '') || item.statusLabel || '';
749
776
  }
750
777
 
751
- async function renderTimelineItem({ document, parent, item, x, y, width, theme, appearance, context, warnings, signal }) {
778
+ function timelineItemTimeField(item) {
779
+ if (item?.timeField) return item.timeField;
780
+ if (item?.kind === 'transition') return 'occurred';
781
+ if (item?.status === 'active') return 'start';
782
+ return 'end';
783
+ }
784
+
785
+ async function renderTimelineItem({ document, parent, item, x, y, width, theme, appearance, context, warnings, signal, i18n = DEFAULT_I18N, timeConfig = null }) {
752
786
  const itemTone = tone(theme, appearance.resolveStatus(item.status));
753
787
  const actions = item.actions || [];
754
788
  const actionTotal = actions.reduce((sum, action) => sum + actionHeight(action) + 8, 0);
@@ -763,17 +797,17 @@ async function renderTimelineItem({ document, parent, item, x, y, width, theme,
763
797
  let textX = contentX;
764
798
  if (people.length) {
765
799
  const stackWidth = await renderTimelineAvatars({
766
- document, parent, people, x: contentX, y: y + 6, theme, context, warnings, signal, item,
800
+ document, parent, people, x: contentX, y: y + 6, theme, context, warnings, signal, item, i18n,
767
801
  });
768
802
  textX = contentX + stackWidth + 8;
769
803
  }
770
- parent.appendChild(svgElement(document, 'text', { x: textX, y: y + 20, fill: theme.colors.text, 'font-size': 15, 'font-weight': 650, 'font-family': theme.fontFamily }, `${item.name}${item.round > 1 ? ` 第 ${item.round} 次` : ''}`));
771
- parent.appendChild(svgElement(document, 'text', { x: contentX + contentWidth, y: y + 20, 'text-anchor': 'end', fill: itemTone.foreground, 'font-size': 12, 'font-weight': 600, 'font-family': theme.fontFamily }, resultLabel(item)));
804
+ parent.appendChild(svgElement(document, 'text', { x: textX, y: y + 20, fill: theme.colors.text, 'font-size': 15, 'font-weight': 650, 'font-family': theme.fontFamily }, `${item.name}${item.round > 1 ? ` ${i18n.t('timeline.round', { round: item.round })}` : ''}`));
805
+ parent.appendChild(svgElement(document, 'text', { x: contentX + contentWidth, y: y + 20, 'text-anchor': 'end', fill: itemTone.foreground, 'font-size': 12, 'font-weight': 600, 'font-family': theme.fontFamily }, resultLabel(item, i18n)));
772
806
  parent.appendChild(svgElement(document, 'text', { x: textX, y: y + 42, fill: theme.colors.textSecondary, 'font-size': 11.5, 'font-family': theme.fontFamily }, item.summary || ''));
773
- parent.appendChild(svgElement(document, 'text', { x: contentX + contentWidth, y: y + 42, 'text-anchor': 'end', fill: theme.colors.textMuted, 'font-size': 11, 'font-family': theme.fontFamily }, formatTime(item.time)));
807
+ parent.appendChild(svgElement(document, 'text', { x: contentX + contentWidth, y: y + 42, 'text-anchor': 'end', fill: theme.colors.textMuted, 'font-size': 11, 'font-family': theme.fontFamily }, formatTime(item.time, timelineItemTimeField(item), timeConfig)));
774
808
  let actionY = y + 56;
775
809
  for (const action of actions) {
776
- const actionHeightValue = await renderTimelineAction({ document, parent, action, x: contentX, y: actionY, width: contentWidth, theme, appearance, context, warnings, signal });
810
+ const actionHeightValue = await renderTimelineAction({ document, parent, action, x: contentX, y: actionY, width: contentWidth, theme, appearance, context, warnings, signal, i18n, timeConfig });
777
811
  actionY += actionHeightValue + 8;
778
812
  }
779
813
  return height;
@@ -782,14 +816,20 @@ async function renderTimelineItem({ document, parent, item, x, y, width, theme,
782
816
  export async function exportRuntimeTimelineSvg(context = {}, options = {}) {
783
817
  options.signal?.throwIfAborted?.();
784
818
  const document = resolvedDocument(context);
819
+ const i18n = resolveExportI18n(context, options);
820
+ const timeConfig = {
821
+ formatRuntimeTime: options.formatRuntimeTime ?? context.formatRuntimeTime ?? null,
822
+ runtimeTimeFormat: options.runtimeTimeFormat ?? context.runtimeTimeFormat ?? null,
823
+ locale: i18n.locale,
824
+ };
785
825
  const projection = context.projection || { items: [], groups: [], links: [] };
786
826
  const theme = themeSnapshot(context, options);
787
- const appearance = context.runtimeAppearance?.resolveStatus ? context.runtimeAppearance : createRuntimeAppearance(context.runtimeAppearance || {});
827
+ const appearance = context.runtimeAppearance?.resolveStatus ? context.runtimeAppearance : createRuntimeAppearance(context.runtimeAppearance || {}, { i18n });
788
828
  const warnings = [];
789
829
  const width = Math.max(640, finite(options.width, 960));
790
830
  const padding = Math.max(0, finite(options.padding, DEFAULT_PADDING));
791
- const title = options.title ?? context.title ?? context.model?.name ?? '审批轨迹';
792
- const description = options.description ?? context.description ?? '按实际处理顺序展示';
831
+ const title = options.title ?? context.title ?? context.model?.name ?? i18n.t('timeline.defaultTitle');
832
+ const description = options.description ?? context.description ?? i18n.t('timeline.defaultDescription');
793
833
  const sequence = timelineSequence(projection);
794
834
  const contentHeight = sequence.reduce((sum, entry) => {
795
835
  if (entry.kind === 'parallel-group') {
@@ -800,7 +840,7 @@ export async function exportRuntimeTimelineSvg(context = {}, options = {}) {
800
840
  }, 0);
801
841
  const headerHeight = title || description ? 74 : 0;
802
842
  const height = Math.max(240, padding * 2 + headerHeight + contentHeight);
803
- const svg = createRoot(document, { minX: 0, minY: 0, width, height, title: title || '审批轨迹', theme, transparentBackground: options.transparentBackground === true });
843
+ const svg = createRoot(document, { minX: 0, minY: 0, width, height, title: title || i18n.t('timeline.defaultTitle'), theme, transparentBackground: options.transparentBackground === true });
804
844
  addDefinitions(document, svg, theme);
805
845
  const root = svgElement(document, 'g', { 'data-layer': 'runtime-timeline' });
806
846
  if (title) root.appendChild(svgElement(document, 'text', { x: padding, y: padding + 20, fill: theme.colors.text, 'font-size': 20, 'font-weight': 700, 'font-family': theme.fontFamily }, title));
@@ -811,11 +851,23 @@ export async function exportRuntimeTimelineSvg(context = {}, options = {}) {
811
851
  if (typeof customRenderer === 'function') {
812
852
  const customLayer = svgElement(document, 'g', { 'data-layer': 'custom-runtime-timeline' });
813
853
  try {
814
- const result = await customRenderer({ container: customLayer, document, projection, model: context.model, runtime: context.runtime, themeSnapshot: theme, appearance, resolveAsset: context.resolveAsset, signal: options.signal });
854
+ const result = await customRenderer({
855
+ container: customLayer,
856
+ document,
857
+ projection,
858
+ model: context.model,
859
+ runtime: context.runtime,
860
+ themeSnapshot: theme,
861
+ appearance,
862
+ resolveAsset: context.resolveAsset,
863
+ formatTime: (value, field = 'occurred') => formatTime(value, field, timeConfig),
864
+ i18n,
865
+ signal: options.signal,
866
+ });
815
867
  if (result?.height) customHeight = Math.max(0, finite(result.height));
816
868
  root.appendChild(customLayer);
817
869
  } catch (error) {
818
- warnings.push({ code: 'custom-timeline-renderer-failed', message: '自定义时间线 SVG Renderer 执行失败,已使用默认时间线。' });
870
+ warnings.push({ code: 'custom-timeline-renderer-failed', message: i18n.t('exportSvg.warnings.customTimelineRendererFailed') });
819
871
  }
820
872
  }
821
873
  if (!customRenderer || warnings.some((warning) => warning.code === 'custom-timeline-renderer-failed')) {
@@ -824,12 +876,12 @@ export async function exportRuntimeTimelineSvg(context = {}, options = {}) {
824
876
  if (entry.kind === 'parallel-group') {
825
877
  const groupTone = tone(theme, appearance.resolveStatus(entry.status));
826
878
  root.appendChild(svgElement(document, 'rect', { x: padding, y, width: width - padding * 2, height: 36, rx: 8, fill: theme.colors.surfaceSubtle }));
827
- root.appendChild(svgElement(document, 'text', { x: padding + 14, y: y + 23, fill: groupTone.foreground, 'font-size': 13, 'font-weight': 650, 'font-family': theme.fontFamily }, `${entry.label} · ${entry.completed}/${entry.total} 已完成`));
879
+ root.appendChild(svgElement(document, 'text', { x: padding + 14, y: y + 23, fill: groupTone.foreground, 'font-size': 13, 'font-weight': 650, 'font-family': theme.fontFamily }, i18n.t('timeline.parallelSvgHeader', { label: entry.label, completed: entry.completed, total: entry.total })));
828
880
  y += 50;
829
881
  const children = (entry.itemIds || []).map((id) => projection.items.find((item) => item.id === id)).filter(Boolean).sort((a, b) => a.order - b.order);
830
- for (const child of children) y += await renderTimelineItem({ document, parent: root, item: child, x: padding + 18, y, width: width - padding * 2 - 18, theme, appearance, context, warnings, signal: options.signal }) + 16;
882
+ for (const child of children) y += await renderTimelineItem({ document, parent: root, item: child, x: padding + 18, y, width: width - padding * 2 - 18, theme, appearance, context, warnings, signal: options.signal, i18n, timeConfig }) + 16;
831
883
  } else {
832
- y += await renderTimelineItem({ document, parent: root, item: entry, x: padding, y, width: width - padding * 2, theme, appearance, context, warnings, signal: options.signal }) + 16;
884
+ y += await renderTimelineItem({ document, parent: root, item: entry, x: padding, y, width: width - padding * 2, theme, appearance, context, warnings, signal: options.signal, i18n, timeConfig }) + 16;
833
885
  }
834
886
  }
835
887
  }
@@ -839,7 +891,7 @@ export async function exportRuntimeTimelineSvg(context = {}, options = {}) {
839
891
  svg.setAttribute('viewBox', `0 0 ${width} ${actualHeight}`);
840
892
  const background = svg.querySelector(':scope > rect');
841
893
  if (background) background.setAttribute('height', String(actualHeight));
842
- const filename = sanitizeSvgFilename(options.filename || `${context.model?.name || 'process'}-${context.label || '移动时间线'}`);
894
+ const filename = sanitizeSvgFilename(options.filename || `${context.model?.name || 'process'}-${context.label || i18n.t('exportSvg.defaultLabels.timeline')}`);
843
895
  return serializeArtifact(document, svg, { filename, width, height: actualHeight, viewBox: { x: 0, y: 0, width, height: actualHeight }, warnings });
844
896
  }
845
897