timeline-canvas 1.3.0 → 1.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 (38) hide show
  1. package/README.md +21 -0
  2. package/README_CN.md +21 -0
  3. package/dist/ContextMenuPlugin-1N7od2I9.mjs +1 -0
  4. package/dist/{ContextMenuPlugin-HeXhKHl7.d.mts → ContextMenuPlugin-Ce29-J1v.d.mts} +1 -1
  5. package/dist/{DarkThemePlugin-Dy3wNEsj.d.mts → DarkThemePlugin-CLhvSrRp.d.mts} +1 -1
  6. package/dist/{DarkThemePlugin-GyV1mhmz.mjs → DarkThemePlugin-CqLyur3d.mjs} +1 -1
  7. package/dist/EventMediaPlugin-C2MC2ruT.mjs +1 -0
  8. package/dist/{EventMediaPlugin-oiYZdX1E.d.mts → EventMediaPlugin-DOIU5CZW.d.mts} +1 -1
  9. package/dist/{EventTooltipPlugin-BVStLFz2.d.mts → EventTooltipPlugin-BtU0ZtyW.d.mts} +1 -1
  10. package/dist/EventTooltipPlugin-Ch_xSklt.mjs +1 -0
  11. package/dist/{LightThemePlugin-ChMBy0bg.d.mts → LightThemePlugin-KFUJdO1V.d.mts} +1 -1
  12. package/dist/{LightThemePlugin-wHpjmbXj.mjs → LightThemePlugin-pQcTWONZ.mjs} +1 -1
  13. package/dist/PerformanceOverlayPlugin-BjEF-I5h.mjs +1 -0
  14. package/dist/{PerformanceOverlayPlugin-DFK_Clxo.d.mts → PerformanceOverlayPlugin-BmjL92Bg.d.mts} +1 -1
  15. package/dist/builtin-plugin/ContextMenuPlugin.d.mts +2 -2
  16. package/dist/builtin-plugin/ContextMenuPlugin.mjs +1 -1
  17. package/dist/builtin-plugin/DarkThemePlugin.d.mts +2 -2
  18. package/dist/builtin-plugin/DarkThemePlugin.mjs +1 -1
  19. package/dist/builtin-plugin/EventMediaPlugin.d.mts +2 -2
  20. package/dist/builtin-plugin/EventMediaPlugin.mjs +1 -1
  21. package/dist/builtin-plugin/EventTooltipPlugin.d.mts +2 -2
  22. package/dist/builtin-plugin/EventTooltipPlugin.mjs +1 -1
  23. package/dist/builtin-plugin/LightThemePlugin.d.mts +2 -2
  24. package/dist/builtin-plugin/LightThemePlugin.mjs +1 -1
  25. package/dist/builtin-plugin/MutexGuardPlugin.d.mts +1 -1
  26. package/dist/builtin-plugin/MutexGuardPlugin.mjs +1 -1
  27. package/dist/builtin-plugin/PerformanceOverlayPlugin.d.mts +2 -2
  28. package/dist/builtin-plugin/PerformanceOverlayPlugin.mjs +1 -1
  29. package/dist/index.d.mts +10 -11
  30. package/dist/index.mjs +1 -1
  31. package/dist/{types-CutIkjn4.d.mts → types-BovVI9wC.d.mts} +184 -36
  32. package/dist/types-Dc2ct_CM.mjs +1 -0
  33. package/package.json +53 -48
  34. package/dist/ContextMenuPlugin-6qe5xYCu.mjs +0 -1
  35. package/dist/EventMediaPlugin-CpPjf_yG.mjs +0 -1
  36. package/dist/EventTooltipPlugin-DNGXHYbN.mjs +0 -1
  37. package/dist/PerformanceOverlayPlugin-CcYPPPIx.mjs +0 -1
  38. package/dist/types-BvVk5Y9C.mjs +0 -1
package/README.md CHANGED
@@ -65,6 +65,10 @@ The `Timeline` constructor accepts an options object:
65
65
 
66
66
  ```typescript
67
67
  interface TimelineOptions {
68
+ // Localization
69
+ locale?: "en" | "zh" | "zh-CN";
70
+ messages?: Partial<TimelineI18nMessages>;
71
+
68
72
  // Dimensions
69
73
  canvasHeight?: number;
70
74
  trackHeight?: number;
@@ -99,6 +103,23 @@ interface TimelineOptions {
99
103
  }
100
104
  ```
101
105
 
106
+ ### Localization
107
+
108
+ Built-in status text, default context menu labels, and performance overlay labels can be localized with `locale` or overridden with `messages`:
109
+
110
+ ```typescript
111
+ import { Timeline } from "timeline-canvas";
112
+
113
+ const timeline = new Timeline("timeline-canvas", {
114
+ locale: "zh-CN",
115
+ messages: {
116
+ statusReady: "已准备",
117
+ },
118
+ });
119
+ ```
120
+
121
+ Built-in plugin metadata also supports localized descriptions via `descriptionI18n`. If you need to render the right description for the current language, use `getPluginMetadataDescription(metadata, locale)`.
122
+
102
123
  ## API Reference
103
124
 
104
125
  ### Core Methods
package/README_CN.md CHANGED
@@ -65,6 +65,10 @@ timeline.addEvent(0, 10, 30, "我的事件", "描述信息");
65
65
 
66
66
  ```typescript
67
67
  interface TimelineOptions {
68
+ // 国际化
69
+ locale?: "en" | "zh" | "zh-CN";
70
+ messages?: Partial<TimelineI18nMessages>;
71
+
68
72
  // 尺寸设置
69
73
  canvasHeight?: number;
70
74
  trackHeight?: number;
@@ -99,6 +103,23 @@ interface TimelineOptions {
99
103
  }
100
104
  ```
101
105
 
106
+ ### 国际化
107
+
108
+ 内置状态提示、默认右键菜单文案和性能面板标签支持通过 `locale` 切换,也可以通过 `messages` 做局部覆盖:
109
+
110
+ ```typescript
111
+ import { Timeline } from "timeline-canvas";
112
+
113
+ const timeline = new Timeline("timeline-canvas", {
114
+ locale: "zh-CN",
115
+ messages: {
116
+ statusReady: "已准备",
117
+ },
118
+ });
119
+ ```
120
+
121
+ 内置插件元信息里的 `description` 也支持通过 `descriptionI18n` 提供多语言版本;如果需要按当前语言渲染描述,可以使用 `getPluginMetadataDescription(metadata, locale)`。
122
+
102
123
  ## API 参考
103
124
 
104
125
  ### 核心方法
@@ -0,0 +1 @@
1
+ import{i as e}from"./Logger-CfVK3yFL.mjs";import{n as t}from"./types-Dc2ct_CM.mjs";const n=e(`ContextMenuPlugin`);function r(e,t){return e(t)}function i(e={}){return{metadata:{name:`context-menu`,version:`1.0.0`,description:`Context menu as plugin, supports HTML takeover`,descriptionI18n:{"zh-CN":`插件化右键菜单,支持 HTML 接管渲染`},type:t.EXTENSION},activate(t){let i=t.config&&t.config.contextMenuHtml||void 0,a=e.htmlTemplate||(typeof i==`string`?i:void 0),o=!!a;o&&(!a||a.trim()===``)&&(n.warn(t.timeline.t(`warningEmptyHtmlTemplateFallback`)),o=!1),t.api.registerRenderLayer({name:`context-menu-overlay`,position:`overlay`,render(e,n,i,s){if(!i.enableContextMenu||!s.contextMenuVisible||!s.contextMenuEvent){let e=r(t.api.getData,`contextMenuContainer`)||null;e&&(e.style.display=`none`),s.contextMenuBounds=null;return}let{padding:c,itemHeight:l,borderRadius:u,borderWidth:d,minWidth:f,fontSize:p,fontFamily:m,fontWeight:h}=i.contextMenuStyle;e.save(),e.font=`${h} ${p}px ${m}`;let g=f,_=`${h}-${p}-${m}`,v=r(t.api.getData,`contextMenuTextWidthCache`)||{},y=v[_]||{};for(let t of i.contextMenuItems){let n=y[t.name],r=n===void 0?e.measureText(t.name).width:n;n===void 0&&(y[t.name]=r),g=Math.max(g,r+c*2)}v[_]=y,t.api.setData(`contextMenuTextWidthCache`,v);let b=g,x=i.contextMenuItems.length*l+c*2,S=t.timeline.getCanvas().getBoundingClientRect(),C=s.contextMenuX,w=s.contextMenuY;if(C+b>S.width&&(C=S.width-b-5),w+x>S.height&&(w=S.height-x-5),s.contextMenuBounds={x:C,y:w,width:b,height:x,itemHeight:l,padding:c},o){let n=r(t.api.getData,`contextMenuContainer`)||null;if(!n){n=document.createElement(`div`),n.style.position=`absolute`,n.style.zIndex=`1000`,n.style.boxShadow=`0 2px 10px rgba(0,0,0,0.3)`,n.style.border=`${d}px solid ${i.colors.contextMenuBorder}`,n.style.borderRadius=`${u}px`,n.style.font=`${h} ${p}px ${m}`,n.style.background=i.colors.contextMenuBackground,n.style.color=i.colors.contextMenuText;let e=t.timeline.getCanvas().parentElement||document.body;e.style.position=e.style.position||`relative`,e.appendChild(n),t.api.setData(`contextMenuContainer`,n)}if(n.style.display=`block`,n.style.left=`${C}px`,n.style.top=`${w}px`,n.style.width=`${b}px`,n.style.height=`${x}px`,a)n.innerHTML=a;else{let e=``;for(let t=0;t<i.contextMenuItems.length;t++){let n=i.contextMenuItems[t],r=s.hoveredContextMenuItem===t,a=r?i.colors.contextMenuHoverBackground:`transparent`,o=r?i.colors.contextMenuHoverText:i.colors.contextMenuText;e+=`<div style="height:${l}px; padding:${c}px; background:${a}; color:${o}; display:flex; align-items:center;">${n.name}</div>`}n.innerHTML=e}e.restore();return}e.shadowColor=`rgba(0, 0, 0, 0.3)`,e.shadowBlur=10,e.shadowOffsetX=0,e.shadowOffsetY=2,e.fillStyle=i.colors.contextMenuBackground,e.beginPath(),e.roundRect?e.roundRect(C,w,b,x,u):(e.moveTo(C+u,w),e.lineTo(C+b-u,w),e.quadraticCurveTo(C+b,w,C+b,w+u),e.lineTo(C+b,w+x-u),e.quadraticCurveTo(C+b,w+x,C+b-u,w+x),e.lineTo(C+u,w+x),e.quadraticCurveTo(C,w+x,C,w+x-u),e.lineTo(C,w+u),e.quadraticCurveTo(C,w,C+u,w)),e.fill(),e.shadowColor=`transparent`,e.strokeStyle=i.colors.contextMenuBorder,e.lineWidth=d,e.stroke(),e.font=`${h} ${p}px ${m}`;for(let t=0;t<i.contextMenuItems.length;t++){let n=i.contextMenuItems[t],r=w+c+t*l;s.hoveredContextMenuItem===t&&(e.fillStyle=i.colors.contextMenuHoverBackground,e.beginPath(),t===0?e.roundRect?e.roundRect(C+d,r,b-d*2,l,[u-d,u-d,0,0]):e.fillRect(C+d,r,b-d*2,l):t===i.contextMenuItems.length-1&&e.roundRect?e.roundRect(C+d,r,b-d*2,l,[0,0,u-d,u-d]):e.fillRect(C+d,r,b-d*2,l),e.fill()),e.fillStyle=s.hoveredContextMenuItem===t?i.colors.contextMenuHoverText:i.colors.contextMenuText,e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(n.name,C+c,r+l/2)}e.restore()}})},deactivate(e){e.api.unregisterRenderLayer(`context-menu-overlay`);let t=r(e.api.getData,`contextMenuContainer`)||null;t&&t.parentElement&&t.parentElement.removeChild(t)},destroy(e){let t=r(e.api.getData,`contextMenuContainer`)||null;t&&t.parentElement&&t.parentElement.removeChild(t)}}}export{i as t};
@@ -1,4 +1,4 @@
1
- import { t as TimelinePlugin } from "./types-CutIkjn4.mjs";
1
+ import { d as TimelinePlugin } from "./types-BovVI9wC.mjs";
2
2
 
3
3
  //#region src/plugins/builtin/ContextMenuPlugin.d.ts
4
4
  interface ContextMenuPluginOptions {
@@ -1,4 +1,4 @@
1
- import { t as TimelinePlugin } from "./types-CutIkjn4.mjs";
1
+ import { d as TimelinePlugin } from "./types-BovVI9wC.mjs";
2
2
 
3
3
  //#region src/plugins/builtin/DarkThemePlugin.d.ts
4
4
  declare const DarkThemePlugin: TimelinePlugin;
@@ -1 +1 @@
1
- import{t as e}from"./types-BvVk5Y9C.mjs";const t={canvasBackground:`#1E1E2E`,timelineBackground:`#2D2D3D`,trackBackground:`#2A2A3A`,trackBackgroundSelected:`#3A3A4A`,timelineText:`#CCCCDD`,timelineGrid:`#5A5A7A`,timelineSubGrid:`#3A3A4A`,trackText:`#CCCCDD`,eventColors:[`#FF6B6B`,`#4ECDC4`,`#45B7D1`,`#96CEB4`,`#FECA57`,`#FF9FF3`],eventText:`#FFFFFF`,eventBorder:`#FFFFFF`,eventBorderSelected:`#FFD700`,eventOverlay:`rgba(255, 255, 255, 0.2)`,dragPreviewValid:`rgba(100, 255, 100, 0.5)`,dragPreviewInvalid:`rgba(255, 100, 100, 0.5)`,dragPreviewBorderValid:`#00FF00`,dragPreviewBorderInvalid:`#FF0000`,timeIndicator:`#FF6B6B`,guideLine:`#00D9FF`,guideLineLabel:`#00D9FF`,dragTimeReferenceLine:`#FFD700`,dragTimeReferenceLabel:`#FFD700`,dragTimeReferenceLabelBackground:`rgba(0, 0, 0, 0)`,scrollbarTrack:`rgba(255, 255, 255, 0.6)`,scrollbarHandle:`rgba(150, 150, 150, 0.8)`,scrollbarHandleHover:`rgba(0, 0, 0, 0.85)`,scrollbarHandleHighlight:`rgba(255, 255, 255, 0.3)`,scrollbarBorder:`rgba(255, 255, 255, 0.9)`,contextMenuBackground:`#2D2D3D`,contextMenuBorder:`#5A5A7A`,contextMenuText:`#CCCCDD`,contextMenuHoverBackground:`#3A3A4A`,contextMenuHoverText:`#FFFFFF`,eventDurationLabel:`#FFD700`},n={metadata:{name:`theme-dark`,version:`1.0.0`,description:`Dark theme for timeline`,type:e.THEME},activate(e){e.config.colors={...e.config.colors,...t},e.api.registerRenderLayer({name:`theme-dark-background`,position:`background`,render(e,t,n){e.fillStyle=n.colors.canvasBackground,e.fillRect(0,0,t.width,t.height)}})},deactivate(e){e.api.unregisterRenderLayer(`theme-dark-background`)}};export{n as t};
1
+ import{n as e}from"./types-Dc2ct_CM.mjs";const t={canvasBackground:`#1E1E2E`,timelineBackground:`#2D2D3D`,trackBackground:`#2A2A3A`,trackBackgroundSelected:`#3A3A4A`,timelineText:`#CCCCDD`,timelineGrid:`#5A5A7A`,timelineSubGrid:`#3A3A4A`,trackText:`#CCCCDD`,eventColors:[`#FF6B6B`,`#4ECDC4`,`#45B7D1`,`#96CEB4`,`#FECA57`,`#FF9FF3`],eventText:`#FFFFFF`,eventBorder:`#FFFFFF`,eventBorderSelected:`#FFD700`,eventOverlay:`rgba(255, 255, 255, 0.1)`,dragPreviewValid:`rgba(100, 255, 100, 0.5)`,dragPreviewInvalid:`rgba(255, 100, 100, 0.5)`,dragPreviewBorderValid:`#00FF00`,dragPreviewBorderInvalid:`#FF0000`,timeIndicator:`#FF6B6B`,guideLine:`#00D9FF`,guideLineLabel:`#00D9FF`,dragTimeReferenceLine:`#FFD700`,dragTimeReferenceLabel:`#FFD700`,dragTimeReferenceLabelBackground:`rgba(0, 0, 0, 0)`,scrollbarTrack:`rgba(255, 255, 255, 0.6)`,scrollbarHandle:`rgba(150, 150, 150, 0.8)`,scrollbarHandleHover:`rgba(0, 0, 0, 0.85)`,scrollbarHandleHighlight:`rgba(255, 255, 255, 0.3)`,scrollbarBorder:`rgba(255, 255, 255, 0.9)`,contextMenuBackground:`#2D2D3D`,contextMenuBorder:`#5A5A7A`,contextMenuText:`#CCCCDD`,contextMenuHoverBackground:`#3A3A4A`,contextMenuHoverText:`#FFFFFF`,eventDurationLabel:`#FFD700`},n={metadata:{name:`theme-dark`,version:`1.0.0`,description:`Dark theme for timeline`,descriptionI18n:{"zh-CN":`时间轴暗色主题`},type:e.THEME},activate(e){e.config.colors={...e.config.colors,...t},e.api.registerRenderLayer({name:`theme-dark-background`,position:`background`,render(e,t,n){e.fillStyle=n.colors.canvasBackground,e.fillRect(0,0,t.width,t.height)}})},deactivate(e){e.api.unregisterRenderLayer(`theme-dark-background`)}};export{n as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./types-Dc2ct_CM.mjs";function t(e,t=!0){let n=Math.round(e),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60;return t?`${r.toString().padStart(2,`0`)}:${i.toString().padStart(2,`0`)}:${a.toString().padStart(2,`0`)}`:`${r.toString().padStart(2,`0`)}:${i.toString().padStart(2,`0`)}`}function n(){let e=new Date;return e.getHours()*3600+e.getMinutes()*60+e.getSeconds()}function r(e,t,n,r,i,a){if(i!=null&&i>0){let t=i/Math.max(1,Math.floor(a??10));return e>=r?t:i}return!n||e<r?t*60:[{threshold:10,seconds:.5},{threshold:8,seconds:1},{threshold:5,seconds:2},{threshold:3,seconds:5},{threshold:2,seconds:10},{threshold:1.5,seconds:15},{threshold:0,seconds:30}].find(t=>e>=t.threshold)?.seconds??30}function i(e,t){return Math.round(e/t)*t}function a(e,t=3){let n=10**t;return Math.round(e*n)/n}function o(e,n){return`${t(e)} - ${t(n)}`}function s(e,n){let r=t(a(e));return n?`${n} ${r}`:r}function c(e,t,n,r,i,a,o=!1){e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.arcTo(t+r,n,t+r,n+a,a),e.lineTo(t+r,n+i-a),e.arcTo(t+r,n+i,t+r-a,n+i,a),e.lineTo(t+a,n+i),e.arcTo(t,n+i,t,n+i-a,a),e.lineTo(t,n+a),e.arcTo(t,n,t+a,n,a),e.closePath(),o?e.stroke():e.fill()}function l(e,t,n,r,i,a){return n+(e-t)*r*i-a}const u={statusReady:`Ready`,statusTrackAdded:`Track added ({count} total)`,statusAtLeastOneTrackRequired:`At least one track is required`,statusTrackRemoved:`Track removed ({count} remaining)`,statusEmptyTrackRemoved:`Empty track removed ({count} remaining)`,statusEventUpdated:`Event updated: {title}`,statusEventDeleted:`Event deleted: {title}`,statusDataLoaded:`Loaded {count} track(s)`,statusTimeIndicatorMoved:`Time indicator moved to: {time}`,statusZoomChanged:`Zoom: {percentage}%`,statusAutoFit:`Auto fit: {percentage}%`,statusAutoFitCappedWithPadding:`Auto fit capped at {percentage}%, added {seconds}s padding`,statusAutoFitCappedContentShort:`Auto fit capped at {percentage}%, content does not fill canvas`,statusEndTimeUpdated:`End time updated: {from} -> {to}`,statusInvalidSplitPosition:`Invalid split position: resulting events too short`,statusEventSplit:`Event split: {title}`,statusReadOnlyModeEnabled:`Read-only mode enabled`,statusReadOnlyModeDisabled:`Read-only mode disabled`,statusEventHighlighted:`Event highlighted: {title}`,statusHighlightCleared:`Highlight cleared`,statusTimelineDestroyed:`Timeline destroyed`,statusDragging:`Dragging: {title}`,statusAutoTrackAdded:`Auto-added track {count}`,statusEventPlaced:`Placed: {title} ({start} - {end})`,statusEventSelected:`Selected: {title}`,statusEventResizing:`Resizing: {start} - {end}`,statusEventResized:`Event resized: {title}`,statusReadOnlyEditDeleteBlocked:`Read-only events cannot be edited or deleted`,statusReadOnlySplitBlocked:`Read-only events cannot be split`,statusHoverEventTimeRange:`{title} ({start} - {end})`,labelTrackName:`Track {index}`,labelDurationPrefix:`Duration`,contextMenuEdit:`Edit`,contextMenuDelete:`Delete`,contextMenuExport:`Export`,overlayPerformanceMonitor:`Performance Monitor`,overlayFps:`FPS: {value}`,overlayLayerTimesMs:`Layer Times (ms):`,overlayCollecting:`Collecting...`,overlayLayerBackground:`Background`,overlayLayerTracks:`Tracks`,overlayLayerTimeline:`Timeline`,overlayLayerGuideLines:`Guide Lines`,overlayLayerIndicator:`Indicator`,overlayLayerScrollbar:`Scrollbar`,overlayLayerInteraction:`Interaction`,overlayLayerOverlay:`Overlay`,overlayLayerDragPreview:`Drag Preview`,errorCanvasNotFound:`Canvas element with id "{canvasId}" not found`,errorCanvasContextUnavailable:`Failed to get 2D context from canvas`,errorTimeIndicatorInvalid:`Time indicator position must be a number (seconds)`,errorZoomLevelInvalid:`Zoom level must be a valid number`,errorZoomLevelOutOfRange:`Zoom level out of valid range (1-1000)`,errorEndTimeInvalid:`End time must be a valid number (seconds)`,errorEndTimeNotAfterStart:`End time must be greater than start time`,warningEventsExceedEndTime:`Warning: some events exceed the new end time`,errorInvalidTrackIndex:`Invalid track index`,errorInvalidTrackIndexWithValue:`Invalid track index: {trackIndex}`,errorInvalidEventIndex:`Invalid event index`,errorInvalidEventIndexWithValue:`Invalid event index: {eventIndex}`,errorInvalidDataFormat:`Invalid data format`,errorInvalidTimeRange:`Invalid time range: startTime={startTime}, endTime={endTime}`,errorStartTimeBeforeMin:`Start time cannot enter left padding: startTime={startTime}, minAllowed={minAllowed}`,errorRenderLayer:`Error rendering layer "{layer}"`,errorCoreLayerHook:`Error in core layer hook "{hook}"`,errorPluginDependenciesMissing:`Plugin dependencies missing: {pluginId}`,errorPluginLoadFailed:`Plugin load failed: {pluginId}`,errorPluginLifecycleFailed:`Plugin {step} failed: {pluginId}`,errorPluginEventFailed:`Plugin event failed: {event}`,errorPluginValidationFailed:`Plugin validation failed: {event}`,warningInvalidDraggingState:`Invalid dragging state`,warningDraggingEventMissing:`Dragging event not found, aborting operation`,warningUnknownChangeType:`Unknown change type: {change}`,warningAlreadyInBatchMode:`Already in batch mode`,warningNotInBatchMode:`Not in batch mode`,warningEmptyHtmlTemplateFallback:`htmlTemplate is empty, falling back to Canvas rendering`,warningEmptyTooltipTemplateFallback:`htmlTemplate returned empty content, falling back to Canvas rendering`},d={statusReady:`就绪`,statusTrackAdded:`已新增轨道(共 {count} 条)`,statusAtLeastOneTrackRequired:`至少需要保留一条轨道`,statusTrackRemoved:`已删除轨道(剩余 {count} 条)`,statusEmptyTrackRemoved:`已移除空轨道(剩余 {count} 条)`,statusEventUpdated:`已更新事件:{title}`,statusEventDeleted:`已删除事件:{title}`,statusDataLoaded:`已加载 {count} 条轨道`,statusTimeIndicatorMoved:`时间指示器已移动到:{time}`,statusZoomChanged:`缩放:{percentage}%`,statusAutoFit:`自动适配:{percentage}%`,statusAutoFitCappedWithPadding:`自动适配已限制为 {percentage}%,并补充了 {seconds} 秒留白`,statusAutoFitCappedContentShort:`自动适配已限制为 {percentage}%,内容仍未铺满画布`,statusEndTimeUpdated:`结束时间已更新:{from} -> {to}`,statusInvalidSplitPosition:`分割位置无效:分割后的事件过短`,statusEventSplit:`已分割事件:{title}`,statusReadOnlyModeEnabled:`已启用只读模式`,statusReadOnlyModeDisabled:`已关闭只读模式`,statusEventHighlighted:`已高亮事件:{title}`,statusHighlightCleared:`已清除高亮`,statusTimelineDestroyed:`时间轴已销毁`,statusDragging:`正在拖拽:{title}`,statusAutoTrackAdded:`已自动新增轨道 {count}`,statusEventPlaced:`已放置:{title}({start} - {end})`,statusEventSelected:`已选中:{title}`,statusEventResizing:`正在调整大小:{start} - {end}`,statusEventResized:`已调整事件大小:{title}`,statusReadOnlyEditDeleteBlocked:`只读事件不能编辑或删除`,statusReadOnlySplitBlocked:`只读事件不能分割`,statusHoverEventTimeRange:`{title}({start} - {end})`,labelTrackName:`轨道 {index}`,labelDurationPrefix:`时长`,contextMenuEdit:`编辑`,contextMenuDelete:`删除`,contextMenuExport:`导出`,overlayPerformanceMonitor:`性能监视器`,overlayFps:`FPS:{value}`,overlayLayerTimesMs:`图层耗时(ms):`,overlayCollecting:`采集中...`,overlayLayerBackground:`背景`,overlayLayerTracks:`轨道`,overlayLayerTimeline:`时间轴`,overlayLayerGuideLines:`辅助线`,overlayLayerIndicator:`指示器`,overlayLayerScrollbar:`滚动条`,overlayLayerInteraction:`交互层`,overlayLayerOverlay:`叠加层`,overlayLayerDragPreview:`拖拽预览`,errorCanvasNotFound:`未找到 id 为 "{canvasId}" 的 canvas 元素`,errorCanvasContextUnavailable:`无法从 canvas 获取 2D 上下文`,errorTimeIndicatorInvalid:`时间指示器位置必须是数值(秒)`,errorZoomLevelInvalid:`缩放级别必须是有效数值`,errorZoomLevelOutOfRange:`缩放级别超出有效范围(1-1000)`,errorEndTimeInvalid:`结束时间必须是有效数值(秒)`,errorEndTimeNotAfterStart:`结束时间必须大于开始时间`,warningEventsExceedEndTime:`警告:部分事件超出了新的结束时间`,errorInvalidTrackIndex:`无效的轨道索引`,errorInvalidTrackIndexWithValue:`无效的轨道索引:{trackIndex}`,errorInvalidEventIndex:`无效的事件索引`,errorInvalidEventIndexWithValue:`无效的事件索引:{eventIndex}`,errorInvalidDataFormat:`无效的数据格式`,errorInvalidTimeRange:`无效的时间范围:startTime={startTime}, endTime={endTime}`,errorStartTimeBeforeMin:`开始时间不能进入左侧留白区域:startTime={startTime}, minAllowed={minAllowed}`,errorRenderLayer:`渲染图层 "{layer}" 时发生错误`,errorCoreLayerHook:`执行核心图层钩子 "{hook}" 时发生错误`,errorPluginDependenciesMissing:`插件依赖缺失:{pluginId}`,errorPluginLoadFailed:`插件加载失败:{pluginId}`,errorPluginLifecycleFailed:`插件 {step} 执行失败:{pluginId}`,errorPluginEventFailed:`插件事件处理失败:{event}`,errorPluginValidationFailed:`插件校验失败:{event}`,warningInvalidDraggingState:`拖拽状态无效`,warningDraggingEventMissing:`无法找到拖拽的事件,已放弃操作`,warningUnknownChangeType:`未知的变更类型:{change}`,warningAlreadyInBatchMode:`当前已处于批量模式`,warningNotInBatchMode:`当前不在批量模式中`,warningEmptyHtmlTemplateFallback:`htmlTemplate 为空,已回退到 Canvas 渲染`,warningEmptyTooltipTemplateFallback:`htmlTemplate 返回空内容,已回退到 Canvas 渲染`},f={en:u,"zh-CN":d};function p(e){return e&&e.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`}function m(e=`en`,t={}){return{...f[p(e)],...t}}function h(e,t,n={}){return e[t].replace(/\{(\w+)\}/g,(e,t)=>t in n?String(n[t]):e)}function g(e,t,n={}){return h(e.messages||m(e.locale),t,n)}function _(e=`en`,t={}){let n=typeof e==`string`?m(e,t):e;return[{type:`edit`,name:n.contextMenuEdit},{type:`delete`,name:n.contextMenuDelete},{type:`export`,name:n.contextMenuExport}]}const v=m(`en`),y={canvasBackground:`#1E1E2E`,timelineBackground:`#2D2D3D`,trackBackground:`#2A2A3A`,trackBackgroundSelected:`#3A3A4A`,timelineText:`#CCCCDD`,timelineGrid:`#5A5A7A`,timelineSubGrid:`#3A3A4A`,trackText:`#CCCCDD`,eventColors:[`#FF6B6B`,`#4ECDC4`,`#45B7D1`,`#96CEB4`,`#FECA57`,`#FF9FF3`],eventText:`#FFFFFF`,eventBorder:`#FFFFFF`,eventBorderSelected:`#FFD700`,eventOverlay:`rgba(255, 255, 255, 0.2)`,dragPreviewValid:`rgba(100, 255, 100, 0.5)`,dragPreviewInvalid:`rgba(255, 100, 100, 0.5)`,dragPreviewBorderValid:`#00FF00`,dragPreviewBorderInvalid:`#FF0000`,timeIndicator:`#FF6B6B`,guideLine:`#00D9FF`,guideLineLabel:`#00D9FF`,dragTimeReferenceLine:`#FFD700`,dragTimeReferenceLabel:`#FFD700`,dragTimeReferenceLabelBackground:`rgba(0, 0, 0, 0)`,scrollbarTrack:`rgba(255, 255, 255, 0.6)`,scrollbarHandle:`rgba(150, 150, 150, 0.8)`,scrollbarHandleHover:`rgba(0, 0, 0, 0.85)`,scrollbarHandleHighlight:`rgba(255, 255, 255, 0.3)`,scrollbarBorder:`rgba(255, 255, 255, 0.9)`,contextMenuBackground:`#2D2D3D`,contextMenuBorder:`#5A5A7A`,contextMenuText:`#CCCCDD`,contextMenuHoverBackground:`#3A3A4A`,contextMenuHoverText:`#FFFFFF`,eventDurationLabel:`#FFD700`},b={titleFontSize:`auto`,timeFontSize:`auto`,titleFontFamily:`Arial`,timeFontFamily:`Arial`,titleFontWeight:`bold`,timeFontWeight:`normal`,titleColor:null,timeColor:null,textAlign:`left`,verticalAlign:`middle`,titleOffsetY:0,timeOffsetY:0,showTitle:!0,showTime:!0,minHeightForTitle:40,minHeightForTime:50},x={borderRadius:2,enableSelectionGlow:!1,selectionGlowBlur:10};_(v);const S={fontSize:14,fontFamily:`Arial, sans-serif`,fontWeight:`normal`,padding:8,itemHeight:32,borderRadius:6,borderWidth:1,minWidth:120},C={timelineHeight:40,trackHeight:80,trackMargin:10,firstTrackTopMargin:10,secondWidth:100/3600,startTime:0,endTime:86400,startPaddingTime:.5,endPaddingTime:0,autoFitOnInit:!0,minAutoFitZoom:1,maxAutoFitZoom:3,locale:`en`,messages:v,timeUnit:`second`,timeFormat:`24h`,snapInterval:15,snapToSeconds:!0,secondPrecisionZoomThreshold:1.5,timeIndicatorWidth:3,timeIndicatorSnapThreshold:10,timeIndicatorHeadSize:12,timeIndicatorTriangleHeight:8,edgeScrollThrottle:80,edgeScrollTriggerMargin:30,edgeScrollViewportMargin:50,guideLineSnapThreshold:1,enableTimeIndicator:!0,enableEventResize:!0,enableEventSplit:!0,enableContextMenu:!0,resizeHandleWidth:8,minEventDuration:.25,debug:!1,enablePerformanceMonitor:!1,autoAddTrack:!0,autoRemoveEmptyLastTrack:!0,readOnly:!1,showEventDurationLabel:!0,eventDurationPrefix:v.labelDurationPrefix,formatEventDuration:null,scale:null,scaleSplitCount:10,getScaleRender:null};function w(e){return typeof structuredClone==`function`?structuredClone(e):T(e)}function T(e){let t=Object.entries(e).map(([e,t])=>[e,D(t)]);return Object.fromEntries(t)}function E(e){return e.map(e=>D(e))}function D(e){return Array.isArray(e)?E(e):k(e)?T(e):e}function O(e){if(e.media)return{...e.media.images?{images:e.media.images.map(e=>({src:e.src,...e.fit?{fit:e.fit}:{},...e.opacity===void 0?{}:{opacity:e.opacity}}))}:{},...e.media.waveform?{waveform:{data:e.media.waveform.data,...e.media.waveform.color?{color:e.media.waveform.color}:{},...e.media.waveform.backgroundColor?{backgroundColor:e.media.waveform.backgroundColor}:{},...e.media.waveform.opacity===void 0?{}:{opacity:e.media.waveform.opacity}}}:{}}}function k(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function A(e){return{id:e.id,startTime:e.startTime,endTime:e.endTime,duration:e.duration,title:e.title,description:e.description,color:e.color,...e.readonly?{readonly:e.readonly}:{},...e.customData?{customData:w(e.customData)}:{},...e.media?{media:O(e)}:{}}}const j=new Map,M=new Map;function N(e,t,n,r){let i=j.get(e);if(i)return i;let a=new Path2D,o=r/2,s=Math.max(1,Math.floor((r-2)/2)),c=t.length,l=Math.max(1,n-1);for(let e=0;e<n;e++){let n=Math.min(c-1,Math.max(0,Math.floor(e/l*c))),r=Math.max(-1,Math.min(1,t[n]))*s;a.moveTo(e,o-r),a.lineTo(e,o+r)}return j.set(e,a),a}function P(e,t,n,r,i,a){let o=M.get(e);if(o&&o.width===n&&o.height===r)return o.bitmap;if(typeof OffscreenCanvas>`u`||n<=0||r<=0)return null;try{let o=Math.max(1,Math.ceil(n)),s=Math.max(1,Math.ceil(r)),c=new OffscreenCanvas(o,s),l=c.getContext(`2d`);if(!l)return null;a&&(l.fillStyle=a,l.fillRect(0,0,o,s));let u=N(`${e}_path`,t,o,s);l.strokeStyle=i,l.lineWidth=1,l.stroke(u);let d=c.transferToImageBitmap(),f=M.get(e);return f&&f.bitmap.close(),M.set(e,{bitmap:d,width:o,height:s}),d}catch(e){return console.debug(`[EventMediaPlugin] Failed to create waveform bitmap`,e),null}}function F(e,t){return e(t)}function I(e,t,n,r){let i=e.ids.get(t);if(i)return i;let a=`event_media_${e.nextId}_${n}_${r}`;return e.nextId+=1,e.ids.set(t,a),a}function L(){return{metadata:{name:`event-media`,version:`1.0.0`,description:`Render images and waveforms inside event blocks`,descriptionI18n:{"zh-CN":`在事件块内渲染图片和波形`},type:e.RENDER},async activate(e){let t={ids:new WeakMap,nextId:0},n=new Map,r=new Map,i=new Map;e.api.setData(`eventMediaIdentityStore`,t),e.api.setData(`eventMediaImageCache`,n),e.api.setData(`eventMediaImageLoading`,r),e.api.setData(`eventMediaWaveCache`,i);let a=(t,n,r,i,a,o,s,l,u,d,f)=>{let p=F(e.api.getData,`eventMediaImageCache`),m=F(e.api.getData,`eventMediaImageLoading`),h=F(e.api.getData,`eventMediaWaveCache`),g=F(e.api.getData,`eventMediaIdentityStore`),_=i.tracks[a].events[o];if(!_.media||!g)return;let v=l+d,y=r.eventBlockStyle.borderRadius,b=I(g,_,a,o);t.save();try{y>0?(c(t,s,v,u,f,y),t.clip()):(t.beginPath(),t.rect(s,v,u,f),t.clip());let e=_.media.images||[];if(e.length>0&&p&&m)for(let n of e){let e=`${b}_${n.src}`,r=p.get(e);if(!r&&!m.get(e)){let t=fetch(n.src).then(e=>e.blob()).then(e=>createImageBitmap(e)).then(t=>(p.set(e,t),m.delete(e),t)).catch(t=>{console.debug(`[EventMediaPlugin] Failed to load event image`,t),m.delete(e)});m.set(e,t)}if(r=p.get(e),r){let e=n.fit||`cover`,i=n.opacity===void 0?.35:n.opacity,a=u,o=f;if(e!==`stretch`){let t=r.width,n=r.height,i=e===`cover`?Math.max(u/t,f/n):Math.min(u/t,f/n);a=Math.max(1,Math.floor(t*i)),o=Math.max(1,Math.floor(n*i))}let c=s+(u-a)/2,l=v+(f-o)/2,d=t.globalAlpha;t.globalAlpha=i,t.drawImage(r,0,0,r.width,r.height,c,l,a,o),t.globalAlpha=d}}let n=_.media.waveform;if(n){let e=`${b}_wf`,r=h?h.get(e):void 0;r||(r=Array.isArray(n.data)?new Float32Array(n.data):n.data,h&&h.set(e,r));let i=n.opacity===void 0?.5:n.opacity,a=t.globalAlpha;t.globalAlpha=i;let o=n.color||`#00A0FF`,c=Math.max(1,Math.ceil(u)),l=Math.max(1,Math.ceil(f)),d=P(`${e}_${c}_${l}_${o}_${n.backgroundColor||``}`,r,c,l,o,n.backgroundColor);if(d)t.drawImage(d,s,v,u,f);else{n.backgroundColor&&(t.fillStyle=n.backgroundColor,t.fillRect(s,v,u,f));let i=N(`${e}_${c}_${l}`,r,c,l);t.save(),t.translate(s,v),t.strokeStyle=o,t.lineWidth=1,t.stroke(i),t.restore()}t.globalAlpha=a}}finally{t.restore()}};e.api.registerEventHandler(`render:event:media`,a),e.api.setData(`eventMediaHandler`,a)},deactivate(e){let t=F(e.api.getData,`eventMediaHandler`);t&&e.api.unregisterEventHandler(`render:event:media`,t);let n=F(e.api.getData,`eventMediaImageCache`);n&&n.clear();let r=F(e.api.getData,`eventMediaImageLoading`);r&&r.clear();let i=F(e.api.getData,`eventMediaWaveCache`);i&&i.clear();for(let e of M.values())e.bitmap.close();M.clear(),j.clear()}}}export{t as _,S as a,r as b,_ as c,g as d,h as f,s as g,a as h,C as i,m as l,l as m,A as n,x as o,c as p,y as r,b as s,L as t,p as u,o as v,i as x,n as y};
@@ -1,4 +1,4 @@
1
- import { t as TimelinePlugin } from "./types-CutIkjn4.mjs";
1
+ import { d as TimelinePlugin } from "./types-BovVI9wC.mjs";
2
2
 
3
3
  //#region src/plugins/builtin/EventMediaPlugin.d.ts
4
4
  declare function EventMediaPlugin(): TimelinePlugin;
@@ -1,4 +1,4 @@
1
- import { t as TimelinePlugin } from "./types-CutIkjn4.mjs";
1
+ import { d as TimelinePlugin } from "./types-BovVI9wC.mjs";
2
2
 
3
3
  //#region src/plugins/builtin/EventTooltipPlugin.d.ts
4
4
  interface EventTooltipPluginOptions {
@@ -0,0 +1 @@
1
+ import{i as e}from"./Logger-CfVK3yFL.mjs";import{n as t}from"./types-Dc2ct_CM.mjs";const n=e(`EventTooltipPlugin`);function r(e,t){return e(t)}function i(e={}){let{htmlTemplate:i,showDelay:a=300,maxWidth:o=300,padding:s=8,borderRadius:c=4,backgroundColor:l=`#333`,textColor:u=`#fff`,borderColor:d=`#555`,fontSize:f=12,fontFamily:p=`Arial, sans-serif`}=e,m={visible:!1,title:``,x:0,y:0,trackIndex:-1,eventIndex:-1},h=null,g=null;function _(e,t,n){return e.measureText(t).width>n}return{metadata:{name:`event-tooltip`,version:`1.0.0`,description:`Tooltip plugin for displaying full event title when text is truncated`,descriptionI18n:{"zh-CN":`当事件标题被截断时显示完整标题的提示插件`},type:t.EXTENSION},activate(e){let t=e.timeline.getCanvas(),v=!1,y=null,b=n=>{let r=t.getBoundingClientRect(),i=n.clientX-r.left,o=n.clientY-r.top,s=e.config,c=e.state,l=e.timeline.getEventAtPosition(i,o);if(l){let{trackIndex:n,eventIndex:r}=l,u=c.tracks[n]?.events[r];if(!u){S();return}if(g&&g.trackIndex===n&&g.eventIndex===r&&m.visible){m.x=i,m.y=o,e.timeline.draw();return}g={trackIndex:n,eventIndex:r},h&&=(clearTimeout(h),null);let d=u.duration*s.secondWidth*c.zoomLevel-20,f=t.getContext(`2d`);if(!f)return;let p=s.eventTextStyle,v=p.titleFontSize===`auto`?Math.max(10,Math.min(14,s.trackHeight*.175)):p.titleFontSize;f.font=`${p.titleFontWeight} ${v}px ${p.titleFontFamily}`,_(f,u.title,d)?h=setTimeout(()=>{m={visible:!0,title:u.title,x:i,y:o,trackIndex:n,eventIndex:r},e.timeline.draw()},a):S()}else S()},x=e=>{y=e,v||(v=!0,requestAnimationFrame(()=>{v=!1,y&&=(b(y),null)}))},S=()=>{h&&=(clearTimeout(h),null),g=null,m.visible&&(m.visible=!1,e.timeline.draw())},C=()=>{S()};t.addEventListener(`mousemove`,x),t.addEventListener(`mouseleave`,C),e.api.setData(`tooltipMouseMoveHandler`,x),e.api.setData(`tooltipMouseLeaveHandler`,C),e.api.registerRenderLayer({name:`event-tooltip-overlay`,position:`overlay`,render(t,a,h,g){if(!m.visible||!m.title){let t=r(e.api.getData,`tooltipContainer`)||null;t&&(t.style.display=`none`);return}let _=e.timeline.getCanvas().getBoundingClientRect(),v=m.x,y=m.y-10;t.save(),t.font=`${f}px ${p}`;let b=m.title.split(``),x=[],S=``;for(let e of b){let n=S+e;t.measureText(n).width>o-s*2?S?(x.push(S),S=e):x.push(e):S=n}S&&x.push(S);let C=0;for(let e of x){let n=t.measureText(e).width;C=Math.max(C,n)}C=Math.min(C+s*2,o);let w=f*1.4,T=x.length*w+s*2;if(y-=T,v+C>_.width&&(v=_.width-C-5),v<5&&(v=5),y<5&&(y=m.y+20),i){let a=i(m.title);if(!a||a.trim()===``)n.warn(e.timeline.t(`warningEmptyTooltipTemplateFallback`));else{let n=r(e.api.getData,`tooltipContainer`)||null;if(!n){n=document.createElement(`div`),n.style.position=`absolute`,n.style.zIndex=`1001`,n.style.pointerEvents=`none`,n.style.boxShadow=`0 2px 8px rgba(0,0,0,0.3)`,n.style.border=`1px solid ${d}`,n.style.borderRadius=`${c}px`,n.style.padding=`${s}px`,n.style.fontSize=`${f}px`,n.style.fontFamily=p,n.style.backgroundColor=l,n.style.color=u,n.style.maxWidth=`${o}px`,n.style.wordWrap=`break-word`,n.style.whiteSpace=`pre-wrap`;let t=e.timeline.getCanvas().parentElement||document.body;t.style.position=t.style.position||`relative`,t.appendChild(n),e.api.setData(`tooltipContainer`,n)}n.style.display=`block`,n.style.left=`${v}px`,n.style.top=`${y}px`,n.innerHTML=a,t.restore();return}}if(t.shadowColor=`rgba(0, 0, 0, 0.3)`,t.shadowBlur=8,t.shadowOffsetX=0,t.shadowOffsetY=2,t.fillStyle=l,t.beginPath(),t.roundRect)t.roundRect(v,y,C,T,c);else{let e=v,n=y,r=C,i=T,a=c;t.moveTo(e+a,n),t.lineTo(e+r-a,n),t.quadraticCurveTo(e+r,n,e+r,n+a),t.lineTo(e+r,n+i-a),t.quadraticCurveTo(e+r,n+i,e+r-a,n+i),t.lineTo(e+a,n+i),t.quadraticCurveTo(e,n+i,e,n+i-a),t.lineTo(e,n+a),t.quadraticCurveTo(e,n,e+a,n)}t.fill(),t.shadowColor=`transparent`,t.shadowBlur=0,t.strokeStyle=d,t.lineWidth=1,t.stroke(),t.fillStyle=u,t.font=`${f}px ${p}`,t.textAlign=`left`,t.textBaseline=`top`;for(let e=0;e<x.length;e++)t.fillText(x[e],v+s,y+s+e*w);t.restore()}})},deactivate(e){let t=e.timeline.getCanvas(),n=r(e.api.getData,`tooltipMouseMoveHandler`),i=r(e.api.getData,`tooltipMouseLeaveHandler`);n&&t.removeEventListener(`mousemove`,n),i&&t.removeEventListener(`mouseleave`,i),h&&=(clearTimeout(h),null),e.api.unregisterRenderLayer(`event-tooltip-overlay`);let a=r(e.api.getData,`tooltipContainer`)||null;a&&a.parentElement&&a.parentElement.removeChild(a)},destroy(e){let t=r(e.api.getData,`tooltipContainer`)||null;t&&t.parentElement&&t.parentElement.removeChild(t),h&&=(clearTimeout(h),null)}}}export{i as t};
@@ -1,4 +1,4 @@
1
- import { t as TimelinePlugin } from "./types-CutIkjn4.mjs";
1
+ import { d as TimelinePlugin } from "./types-BovVI9wC.mjs";
2
2
 
3
3
  //#region src/plugins/builtin/LightThemePlugin.d.ts
4
4
  declare const LightThemePlugin: TimelinePlugin;
@@ -1 +1 @@
1
- import{t as e}from"./types-BvVk5Y9C.mjs";const t={canvasBackground:`#FFFFFF`,timelineBackground:`#FFFFFF`,trackBackground:`#FFFFFF`,trackBackgroundSelected:`rgba(63, 118, 252, 0.1)`,trackBackgroundOdd:`#FFFFFF`,trackBackgroundEven:`#F9FAFD`,timelineText:`#969BA5`,timelineGrid:`#E5E5E5`,timelineSubGrid:`#fff`,trackText:`#CCCCDD`,eventColors:[`rgba(63, 118, 252, 0.16)`],eventText:`#FFFFFF`,eventBorder:`#FFFFFF`,eventBorderSelected:`#3F76FC`,eventOverlay:`rgba(255, 255, 255, 0.2)`,dragPreviewValid:`rgba(100, 255, 100, 0.5)`,dragPreviewInvalid:`rgba(255, 100, 100, 0.5)`,dragPreviewBorderValid:`#00FF00`,dragPreviewBorderInvalid:`#FF0000`,timeIndicator:`#3F76FC`,guideLine:`#00D9FF`,guideLineLabel:`#00D9FF`,dragTimeReferenceLine:`#FFD700`,dragTimeReferenceLabel:`#FFD700`,dragTimeReferenceLabelBackground:`rgba(0, 0, 0, 0)`,scrollbarTrack:`rgba(63, 118, 252, 0.08)`,scrollbarHandle:`rgba(63, 118, 252, 0.5)`,scrollbarHandleHover:`rgba(63, 118, 252, 0.8)`,scrollbarHandleHighlight:`rgba(63, 118, 252, 0.12)`,scrollbarBorder:`rgba(63, 118, 252, 0.6)`,contextMenuBackground:`#2D2D3D`,contextMenuBorder:`#5A5A7A`,contextMenuText:`#CCCCDD`,contextMenuHoverBackground:`#4a00e0`,contextMenuHoverText:`#FFFFFF`,eventDurationLabel:`#3F76FC`},n={metadata:{name:`theme-light`,version:`1.0.0`,description:`Light theme for timeline`,type:e.THEME},activate(e){e.config.colors={...e.config.colors,...t},e.api.registerRenderLayer({name:`theme-light-background`,position:`background`,render(e,t,n){e.fillStyle=n.colors.canvasBackground,e.fillRect(0,0,t.width,t.height)}})},deactivate(e){e.api.unregisterRenderLayer(`theme-light-background`)}};export{n as t};
1
+ import{n as e}from"./types-Dc2ct_CM.mjs";const t={canvasBackground:`#FFFFFF`,timelineBackground:`#FFFFFF`,trackBackground:`#FFFFFF`,trackBackgroundSelected:`rgba(63, 118, 252, 0.1)`,trackBackgroundOdd:`#FFFFFF`,trackBackgroundEven:`#F9FAFD`,timelineText:`#969BA5`,timelineGrid:`#E5E5E5`,timelineSubGrid:`#fff`,trackText:`#CCCCDD`,eventColors:[`rgba(63, 118, 252, 0.16)`],eventText:`#FFFFFF`,eventBorder:`#FFFFFF`,eventBorderSelected:`#3F76FC`,eventOverlay:`rgba(63, 118, 252, 0.12)`,dragPreviewValid:`rgba(100, 255, 100, 0.5)`,dragPreviewInvalid:`rgba(255, 100, 100, 0.5)`,dragPreviewBorderValid:`#00FF00`,dragPreviewBorderInvalid:`#FF0000`,timeIndicator:`#3F76FC`,guideLine:`#00D9FF`,guideLineLabel:`#00D9FF`,dragTimeReferenceLine:`#FFD700`,dragTimeReferenceLabel:`#FFD700`,dragTimeReferenceLabelBackground:`rgba(0, 0, 0, 0)`,scrollbarTrack:`rgba(63, 118, 252, 0.08)`,scrollbarHandle:`rgba(63, 118, 252, 0.5)`,scrollbarHandleHover:`rgba(63, 118, 252, 0.8)`,scrollbarHandleHighlight:`rgba(63, 118, 252, 0.12)`,scrollbarBorder:`rgba(63, 118, 252, 0.6)`,contextMenuBackground:`#2D2D3D`,contextMenuBorder:`#5A5A7A`,contextMenuText:`#CCCCDD`,contextMenuHoverBackground:`#4a00e0`,contextMenuHoverText:`#FFFFFF`,eventDurationLabel:`#3F76FC`},n={metadata:{name:`theme-light`,version:`1.0.0`,description:`Light theme for timeline`,descriptionI18n:{"zh-CN":`时间轴亮色主题`},type:e.THEME},activate(e){e.config.colors={...e.config.colors,...t},e.api.registerRenderLayer({name:`theme-light-background`,position:`background`,render(e,t,n){e.fillStyle=n.colors.canvasBackground,e.fillRect(0,0,t.width,t.height)}})},deactivate(e){e.api.unregisterRenderLayer(`theme-light-background`)}};export{n as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./performanceMonitor-BBherdD8.mjs";import{n as t}from"./types-Dc2ct_CM.mjs";const n={metadata:{name:`performance-overlay`,version:`1.0.0`,description:`Draw performance metrics overlay`,descriptionI18n:{"zh-CN":`绘制性能指标叠加层`},type:t.TOOL},activate(t){let n={background:`overlayLayerBackground`,tracks:`overlayLayerTracks`,timeline:`overlayLayerTimeline`,interaction:`overlayLayerInteraction`,guideLines:`overlayLayerGuideLines`,scrollbar:`overlayLayerScrollbar`,overlay:`overlayLayerOverlay`,dragPreview:`overlayLayerDragPreview`},r=new e(t.config.enablePerformanceMonitor||t.config.debug);t.api.setPerformanceProvider(r),t.api.setData(`perfMonitor`,r),t.api.setData(`perfOverlayPos`,{x:10,y:10}),t.api.setData(`perfOverlayDragging`,!1),t.api.setData(`perfOverlayOffset`,{x:0,y:0});let i=t.timeline.getCanvas(),a=e=>{let n=i.getBoundingClientRect(),r=e.clientX-n.left,a=e.clientY-n.top,o=t.api.getData(`perfOverlaySize`),s=t.api.getData(`perfOverlayPos`)||{x:10,y:10};o&&r>=s.x&&r<=s.x+o.width&&a>=s.y&&a<=s.y+o.height&&(t.api.setData(`perfOverlayDragging`,!0),t.api.setData(`perfOverlayOffset`,{x:r-s.x,y:a-s.y}),e.stopImmediatePropagation(),e.preventDefault())},o=e=>{if(!t.api.getData(`perfOverlayDragging`))return;let n=i.getBoundingClientRect(),r=e.clientX-n.left,a=e.clientY-n.top,o=t.api.getData(`perfOverlayOffset`)||{x:0,y:0},s=t.api.getData(`perfOverlaySize`)||{width:0,height:0},c=r-o.x,l=a-o.y;c=Math.max(0,Math.min(n.width-s.width,c)),l=Math.max(0,Math.min(n.height-s.height,l)),t.api.setData(`perfOverlayPos`,{x:c,y:l}),t.timeline.markDirty([`overlay`]),t.timeline.draw(),e.stopImmediatePropagation(),e.preventDefault()},s=e=>{t.api.getData(`perfOverlayDragging`)&&t.api.setData(`perfOverlayDragging`,!1)};i.addEventListener(`mousedown`,a,{capture:!0}),i.addEventListener(`mousemove`,o,{capture:!0}),window.addEventListener(`mouseup`,s,{capture:!0}),t.api.setData(`perfOverlayListeners`,{onMouseDown:a,onMouseMove:o,onMouseUp:s}),t.api.registerRenderLayer({name:`performance-overlay`,position:`overlay`,render(e){let r=t.api.getData(`perfMonitor`),i=!!(t.config.enablePerformanceMonitor||t.config.debug);if(r)if(i)r.enable();else{r.disable(),r.clear();return}else if(!i)return;let a=t.api.getPerformanceStats(),o=t.api.getFPS(),s=Array.from(a.entries()),c=[`background`,`tracks`,`timeline`,`interaction`,`guideLines`,`scrollbar`,`overlay`,`dragPreview`],l=t.timeline.getLastLayerTimes?t.timeline.getLastLayerTimes():void 0,u=l?c.filter(e=>l[e]!==void 0).length:0,d=l?1+u:0,f=25+(1+(a.size===0?1:s.length)+d)*20+30,p=t.api.getData(`perfOverlayPos`)||{x:10,y:10};t.api.setData(`perfOverlaySize`,{width:280,height:f}),e.fillStyle=`rgba(0, 0, 0, 0.8)`,e.fillRect(p.x,p.y,280,f),e.strokeStyle=`rgba(100, 255, 100, 0.6)`,e.lineWidth=2,e.strokeRect(p.x,p.y,280,f),e.fillStyle=`#00FF00`,e.font=`bold 16px monospace`,e.textAlign=`left`,e.fillText(t.timeline.t(`overlayPerformanceMonitor`),p.x+10,p.y+20);let m=p.y+20+25;if(e.fillStyle=o>=55?`#00FF00`:o>=30?`#FFFF00`:`#FF0000`,e.font=`bold 14px monospace`,e.fillText(t.timeline.t(`overlayFps`,{value:o.toFixed(1)}),p.x+10,m),e.font=`12px monospace`,m+=20,l){e.fillStyle=`#00FFFF`,e.font=`bold 12px monospace`,e.fillText(t.timeline.t(`overlayLayerTimesMs`),p.x+10,m),m+=20,e.font=`12px monospace`,e.fillStyle=`#FFFFFF`;for(let r of c)l[r]!==void 0&&(e.fillText(`${t.timeline.t(n[r]||`overlayLayerOverlay`)}: ${l[r].toFixed(2)}`,p.x+10,m),m+=20)}a.size===0?(e.fillStyle=`#FFFFFF`,e.fillText(t.timeline.t(`overlayCollecting`),p.x+10,m),m+=20):s.forEach(([t,n])=>{let r=`#00FF00`;n.average>16&&(r=`#FFFF00`),n.average>33&&(r=`#FF0000`),e.fillStyle=r;let i=`${t}: ${n.average.toFixed(2)}ms (${n.min.toFixed(1)}-${n.max.toFixed(1)})`;e.fillText(i,p.x+10,m),m+=20})}})},deactivate(e){e.api.unregisterRenderLayer(`performance-overlay`);let t=e.api.getData(`perfOverlayListeners`),n=e.timeline.getCanvas();t&&(n.removeEventListener(`mousedown`,t.onMouseDown,!0),n.removeEventListener(`mousemove`,t.onMouseMove,!0),window.removeEventListener(`mouseup`,t.onMouseUp,!0))}};export{n as t};
@@ -1,4 +1,4 @@
1
- import { t as TimelinePlugin } from "./types-CutIkjn4.mjs";
1
+ import { d as TimelinePlugin } from "./types-BovVI9wC.mjs";
2
2
 
3
3
  //#region src/plugins/builtin/PerformanceOverlayPlugin.d.ts
4
4
  declare const PerformanceOverlayPlugin: TimelinePlugin;
@@ -1,3 +1,3 @@
1
- import "../types-CutIkjn4.mjs";
2
- import { t as ContextMenuPlugin } from "../ContextMenuPlugin-HeXhKHl7.mjs";
1
+ import "../types-BovVI9wC.mjs";
2
+ import { t as ContextMenuPlugin } from "../ContextMenuPlugin-Ce29-J1v.mjs";
3
3
  export { ContextMenuPlugin };
@@ -1 +1 @@
1
- import{t as e}from"../ContextMenuPlugin-6qe5xYCu.mjs";export{e as ContextMenuPlugin};
1
+ import{t as e}from"../ContextMenuPlugin-1N7od2I9.mjs";export{e as ContextMenuPlugin};
@@ -1,3 +1,3 @@
1
- import "../types-CutIkjn4.mjs";
2
- import { t as DarkThemePlugin } from "../DarkThemePlugin-Dy3wNEsj.mjs";
1
+ import "../types-BovVI9wC.mjs";
2
+ import { t as DarkThemePlugin } from "../DarkThemePlugin-CLhvSrRp.mjs";
3
3
  export { DarkThemePlugin as DarkTheme, DarkThemePlugin };
@@ -1 +1 @@
1
- import{t as e}from"../DarkThemePlugin-GyV1mhmz.mjs";export{e as DarkTheme,e as DarkThemePlugin};
1
+ import{t as e}from"../DarkThemePlugin-CqLyur3d.mjs";export{e as DarkTheme,e as DarkThemePlugin};
@@ -1,3 +1,3 @@
1
- import "../types-CutIkjn4.mjs";
2
- import { t as EventMediaPlugin } from "../EventMediaPlugin-oiYZdX1E.mjs";
1
+ import "../types-BovVI9wC.mjs";
2
+ import { t as EventMediaPlugin } from "../EventMediaPlugin-DOIU5CZW.mjs";
3
3
  export { EventMediaPlugin };
@@ -1 +1 @@
1
- import{t as e}from"../EventMediaPlugin-CpPjf_yG.mjs";export{e as EventMediaPlugin};
1
+ import{t as e}from"../EventMediaPlugin-C2MC2ruT.mjs";export{e as EventMediaPlugin};
@@ -1,3 +1,3 @@
1
- import "../types-CutIkjn4.mjs";
2
- import { t as EventTooltipPlugin } from "../EventTooltipPlugin-BVStLFz2.mjs";
1
+ import "../types-BovVI9wC.mjs";
2
+ import { t as EventTooltipPlugin } from "../EventTooltipPlugin-BtU0ZtyW.mjs";
3
3
  export { EventTooltipPlugin };
@@ -1 +1 @@
1
- import{t as e}from"../EventTooltipPlugin-DNGXHYbN.mjs";export{e as EventTooltipPlugin};
1
+ import{t as e}from"../EventTooltipPlugin-Ch_xSklt.mjs";export{e as EventTooltipPlugin};
@@ -1,3 +1,3 @@
1
- import "../types-CutIkjn4.mjs";
2
- import { t as LightThemePlugin } from "../LightThemePlugin-ChMBy0bg.mjs";
1
+ import "../types-BovVI9wC.mjs";
2
+ import { t as LightThemePlugin } from "../LightThemePlugin-KFUJdO1V.mjs";
3
3
  export { LightThemePlugin as LightTheme, LightThemePlugin };
@@ -1 +1 @@
1
- import{t as e}from"../LightThemePlugin-wHpjmbXj.mjs";export{e as LightTheme,e as LightThemePlugin};
1
+ import{t as e}from"../LightThemePlugin-pQcTWONZ.mjs";export{e as LightTheme,e as LightThemePlugin};
@@ -1,4 +1,4 @@
1
- import { t as TimelinePlugin } from "../types-CutIkjn4.mjs";
1
+ import { d as TimelinePlugin } from "../types-BovVI9wC.mjs";
2
2
 
3
3
  //#region src/plugins/builtin/MutexGuardPlugin.d.ts
4
4
  declare function MutexGuardPlugin(): TimelinePlugin;
@@ -1 +1 @@
1
- import{t as e}from"../types-BvVk5Y9C.mjs";function t(){return{metadata:{name:`MutexGuardPlugin`,version:`1.0.0`,description:`Disallow parallel existence of mutex-tagged events across tracks`,type:e.EXTENSION},activate(e){e.api.registerEventHandler(`validate:event:move`,t=>{let{fromTrackIndex:n,fromEventIndex:r,newStartTime:i,duration:a}=t,o=e.state,s=i+a,c=o.tracks[n]?.events[r];if(!c)return!0;let l=Array.isArray(c.customData?.mutex)?c.customData.mutex:[];if(l.length===0)return!0;for(let e=0;e<o.tracks.length;e++){let t=o.tracks[e];for(let a=0;a<t.events.length;a++){if(e===n&&a===r)continue;let o=t.events[a],c=Array.isArray(o.customData?.mutex)?o.customData.mutex:[];if(c.length!==0&&l.some(e=>c.includes(e))&&!(s<=o.startTime||i>=o.endTime))return!1}}return!0})}}}export{t as MutexGuardPlugin};
1
+ import{n as e}from"../types-Dc2ct_CM.mjs";function t(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.fromTrackIndex==`number`&&typeof t.fromEventIndex==`number`&&typeof t.newStartTime==`number`&&typeof t.duration==`number`}function n(){function n(e,n){if(!t(e))return!0;let{fromTrackIndex:r,fromEventIndex:i,newStartTime:a,duration:o}=e,s=a+o,c=n.tracks[r]?.events[i];if(!c)return!0;let l=Array.isArray(c.customData?.mutex)?c.customData.mutex:[];if(l.length===0)return!0;for(let e=0;e<n.tracks.length;e++){let t=n.tracks[e];for(let n=0;n<t.events.length;n++){if(e===r&&n===i)continue;let o=t.events[n],c=Array.isArray(o.customData?.mutex)?o.customData.mutex:[];if(c.length!==0&&l.some(e=>c.includes(e))&&!(s<=o.startTime||a>=o.endTime))return!1}}return!0}let r;return{metadata:{name:`MutexGuardPlugin`,version:`1.0.0`,description:`Disallow parallel existence of mutex-tagged events across tracks`,descriptionI18n:{"zh-CN":`禁止带互斥标签的事件在不同轨道上并行存在`},type:e.EXTENSION},activate(e){r=t=>n(t,e.state),e.api.registerEventHandler(`validate:event:move`,r)},deactivate(e){r&&=(e.api.unregisterEventHandler(`validate:event:move`,r),void 0)}}}export{n as MutexGuardPlugin};
@@ -1,3 +1,3 @@
1
- import "../types-CutIkjn4.mjs";
2
- import { t as PerformanceOverlayPlugin } from "../PerformanceOverlayPlugin-DFK_Clxo.mjs";
1
+ import "../types-BovVI9wC.mjs";
2
+ import { t as PerformanceOverlayPlugin } from "../PerformanceOverlayPlugin-BmjL92Bg.mjs";
3
3
  export { PerformanceOverlayPlugin };
@@ -1 +1 @@
1
- import{t as e}from"../PerformanceOverlayPlugin-CcYPPPIx.mjs";export{e as PerformanceOverlayPlugin};
1
+ import{t as e}from"../PerformanceOverlayPlugin-BjEF-I5h.mjs";export{e as PerformanceOverlayPlugin};
package/dist/index.d.mts CHANGED
@@ -1,13 +1,12 @@
1
- import { C as Track, S as TimelineState, _ as TimelineCallbacks, a as ContextMenuItem, b as TimelineEvent, c as EventClickData, d as EventMoveData, f as EventTextStyle, g as TimeIndicatorMoveData, h as LoadDataFormat, i as ContextMenuData, l as EventDeleteData, m as InteractionTarget, n as Timeline, o as ContextMenuStyle, p as EventUpdateData, r as ChangeType, s as EventAddData, u as EventEditData, v as TimelineColors, w as ZoomData, x as TimelineOptions, y as TimelineConfig } from "./types-CutIkjn4.mjs";
2
- import { t as ContextMenuPlugin } from "./ContextMenuPlugin-HeXhKHl7.mjs";
3
- import { t as DarkThemePlugin } from "./DarkThemePlugin-Dy3wNEsj.mjs";
4
- import { t as EventMediaPlugin } from "./EventMediaPlugin-oiYZdX1E.mjs";
5
- import { t as EventTooltipPlugin } from "./EventTooltipPlugin-BVStLFz2.mjs";
6
- import { t as LightThemePlugin } from "./LightThemePlugin-ChMBy0bg.mjs";
7
- import { t as PerformanceOverlayPlugin } from "./PerformanceOverlayPlugin-DFK_Clxo.mjs";
1
+ import { A as TimelineCallbacks, B as ZoomData, C as EventEditData, D as InteractionTarget, E as EventUpdateData, F as TimelineLocale, I as TimelineMessageParams, L as TimelineOptions, M as TimelineConfig, N as TimelineEvent, O as LoadDataFormat, P as TimelineI18nMessages, R as TimelineState, S as EventDeleteData, T as EventTextStyle, _ as ContextMenuData, a as PluginLocalizedText, b as EventAddData, c as PluginType, d as TimelinePlugin, f as Timeline, g as getCurrentTime, h as formatTime, i as PluginContext, j as TimelineColors, k as TimeIndicatorMoveData, l as RenderLayer, m as createTimelineMessages, n as CoreRenderTarget, o as PluginMetadata, p as ChangeType, r as PluginAPI, s as PluginPriority, t as CoreLayerHook, u as RenderLayerPosition, v as ContextMenuItem, w as EventMoveData, x as EventClickData, y as ContextMenuStyle, z as Track } from "./types-BovVI9wC.mjs";
2
+ import { t as ContextMenuPlugin } from "./ContextMenuPlugin-Ce29-J1v.mjs";
3
+ import { t as DarkThemePlugin } from "./DarkThemePlugin-CLhvSrRp.mjs";
4
+ import { t as EventMediaPlugin } from "./EventMediaPlugin-DOIU5CZW.mjs";
5
+ import { t as EventTooltipPlugin } from "./EventTooltipPlugin-BtU0ZtyW.mjs";
6
+ import { t as LightThemePlugin } from "./LightThemePlugin-KFUJdO1V.mjs";
7
+ import { t as PerformanceOverlayPlugin } from "./PerformanceOverlayPlugin-BmjL92Bg.mjs";
8
8
 
9
- //#region src/utils/time.d.ts
10
- declare function formatTime(seconds: number, showSeconds?: boolean): string;
11
- declare function getCurrentTime(): number;
9
+ //#region src/plugins/metadata.d.ts
10
+ declare function getPluginMetadataDescription(metadata: PluginMetadata, locale?: string): string;
12
11
  //#endregion
13
- export { type ChangeType, type ContextMenuData, type ContextMenuItem, ContextMenuPlugin, type ContextMenuStyle, DarkThemePlugin, type EventAddData, type EventClickData, type EventDeleteData, type EventEditData, EventMediaPlugin, type EventMoveData, type EventTextStyle, EventTooltipPlugin, type EventUpdateData, type InteractionTarget, LightThemePlugin, type LoadDataFormat, PerformanceOverlayPlugin, type TimeIndicatorMoveData, Timeline, type TimelineCallbacks, type TimelineColors, type TimelineConfig, type TimelineEvent, type TimelineOptions, type TimelineState, type Track, type ZoomData, formatTime, getCurrentTime };
12
+ export { type ChangeType, type ContextMenuData, type ContextMenuItem, ContextMenuPlugin, type ContextMenuStyle, type CoreLayerHook, type CoreRenderTarget, DarkThemePlugin, type EventAddData, type EventClickData, type EventDeleteData, type EventEditData, EventMediaPlugin, type EventMoveData, type EventTextStyle, EventTooltipPlugin, type EventUpdateData, type InteractionTarget, LightThemePlugin, type LoadDataFormat, PerformanceOverlayPlugin, type PluginAPI, type PluginContext, type PluginLocalizedText, type PluginMetadata, PluginPriority, PluginType, type RenderLayer, type RenderLayerPosition, type TimeIndicatorMoveData, Timeline, type TimelineCallbacks, type TimelineColors, type TimelineConfig, type TimelineEvent, type TimelineI18nMessages, type TimelineLocale, type TimelineMessageParams, type TimelineOptions, type TimelinePlugin, type TimelineState, type Track, type ZoomData, createTimelineMessages, formatTime, getCurrentTime, getPluginMetadataDescription };