timeline-canvas 1.4.0 → 1.5.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 (41) hide show
  1. package/README.md +183 -183
  2. package/README_CN.md +185 -185
  3. package/dist/ContextMenuPlugin-Btbm1QEm.mjs +1 -0
  4. package/dist/{ContextMenuPlugin-Ce29-J1v.d.mts → ContextMenuPlugin-C84Iiz8U.d.mts} +1 -2
  5. package/dist/{DarkThemePlugin-CLhvSrRp.d.mts → DarkThemePlugin-YD-fFNVt.d.mts} +1 -2
  6. package/dist/DarkThemePlugin-pFFtYjOV.mjs +1 -0
  7. package/dist/EventMediaPlugin-BCuSI5ww.mjs +1 -0
  8. package/dist/{EventMediaPlugin-DOIU5CZW.d.mts → EventMediaPlugin-BiG8wzdz.d.mts} +1 -2
  9. package/dist/EventTooltipPlugin-0Dz25qie.mjs +1 -0
  10. package/dist/{EventTooltipPlugin-BtU0ZtyW.d.mts → EventTooltipPlugin-r1624PXo.d.mts} +1 -2
  11. package/dist/LightThemePlugin-BD4cbg_E.mjs +1 -0
  12. package/dist/{LightThemePlugin-KFUJdO1V.d.mts → LightThemePlugin-CGDyxruq.d.mts} +1 -2
  13. package/dist/PerformanceOverlayPlugin-Cph1TMWd.mjs +1 -0
  14. package/dist/{PerformanceOverlayPlugin-BmjL92Bg.d.mts → PerformanceOverlayPlugin-DDmW-ils.d.mts} +1 -2
  15. package/dist/builtin-plugin/ContextMenuPlugin.d.mts +1 -2
  16. package/dist/builtin-plugin/ContextMenuPlugin.mjs +1 -1
  17. package/dist/builtin-plugin/DarkThemePlugin.d.mts +1 -2
  18. package/dist/builtin-plugin/DarkThemePlugin.mjs +1 -1
  19. package/dist/builtin-plugin/EventMediaPlugin.d.mts +1 -2
  20. package/dist/builtin-plugin/EventMediaPlugin.mjs +1 -1
  21. package/dist/builtin-plugin/EventTooltipPlugin.d.mts +1 -2
  22. package/dist/builtin-plugin/EventTooltipPlugin.mjs +1 -1
  23. package/dist/builtin-plugin/LightThemePlugin.d.mts +1 -2
  24. package/dist/builtin-plugin/LightThemePlugin.mjs +1 -1
  25. package/dist/builtin-plugin/MutexGuardPlugin.d.mts +1 -2
  26. package/dist/builtin-plugin/MutexGuardPlugin.mjs +1 -1
  27. package/dist/builtin-plugin/PerformanceOverlayPlugin.d.mts +1 -2
  28. package/dist/builtin-plugin/PerformanceOverlayPlugin.mjs +1 -1
  29. package/dist/index.d.mts +14 -9
  30. package/dist/index.mjs +1 -1
  31. package/dist/{types-BovVI9wC.d.mts → types-Ch6RMCi9.d.mts} +22 -23
  32. package/package.json +15 -14
  33. package/dist/ContextMenuPlugin-1N7od2I9.mjs +0 -1
  34. package/dist/DarkThemePlugin-CqLyur3d.mjs +0 -1
  35. package/dist/EventMediaPlugin-C2MC2ruT.mjs +0 -1
  36. package/dist/EventTooltipPlugin-Ch_xSklt.mjs +0 -1
  37. package/dist/LightThemePlugin-pQcTWONZ.mjs +0 -1
  38. package/dist/PerformanceOverlayPlugin-BjEF-I5h.mjs +0 -1
  39. package/dist/performanceMonitor-BBherdD8.mjs +0 -1
  40. /package/dist/{Logger-CfVK3yFL.mjs → Logger-BX6_sfV3.mjs} +0 -0
  41. /package/dist/{types-Dc2ct_CM.mjs → types-DhRsiQBh.mjs} +0 -0
@@ -171,8 +171,11 @@ interface TimelineConfig {
171
171
  maxAutoFitZoom: number;
172
172
  timeUnit: string;
173
173
  timeFormat: string;
174
+ /** 分钟吸附间隔;仅在关闭秒级吸附且未设置自定义刻度时使用 */
174
175
  snapInterval: number;
176
+ /** 开启后在任意缩放级别按 1 秒吸附,优先于自定义刻度 */
175
177
  snapToSeconds: boolean;
178
+ /** 仅在关闭秒级吸附时控制自定义刻度从主刻度切换为细分刻度 */
176
179
  secondPrecisionZoomThreshold: number;
177
180
  timeIndicatorWidth: number;
178
181
  timeIndicatorSnapThreshold: number;
@@ -469,8 +472,11 @@ interface TimelineOptions {
469
472
  trackMargin?: number;
470
473
  firstTrackTopMargin?: number;
471
474
  timelineHeight?: number;
475
+ /** 分钟吸附间隔;仅在关闭秒级吸附且未设置自定义刻度时使用 */
472
476
  snapInterval?: number;
477
+ /** 开启后在任意缩放级别按 1 秒吸附,优先于自定义刻度 */
473
478
  snapToSeconds?: boolean;
479
+ /** 仅在关闭秒级吸附时控制自定义刻度从主刻度切换为细分刻度 */
474
480
  secondPrecisionZoomThreshold?: number;
475
481
  enableTimeIndicator?: boolean;
476
482
  edgeScrollThrottle?: number;
@@ -523,13 +529,14 @@ declare global {
523
529
  }
524
530
  }
525
531
  //#endregion
526
- //#region src/utils/time.d.ts
527
- declare function formatTime(seconds: number, showSeconds?: boolean): string;
528
- declare function getCurrentTime(): number;
529
- //#endregion
530
532
  //#region src/utils/i18n.d.ts
531
533
  type TimelineMessageKey = keyof TimelineI18nMessages;
534
+ type ResolvedTimelineLocale = Exclude<TimelineLocale, "zh">;
535
+ declare function normalizeTimelineLocale(locale?: string): ResolvedTimelineLocale;
532
536
  declare function createTimelineMessages(locale?: string, overrides?: Partial<TimelineI18nMessages>): TimelineI18nMessages;
537
+ declare function translateTimelineMessage(messages: TimelineI18nMessages, key: TimelineMessageKey, params?: TimelineMessageParams): string;
538
+ declare function translateTimelineConfig(config: Pick<TimelineConfig, "locale" | "messages">, key: TimelineMessageKey, params?: TimelineMessageParams): string;
539
+ declare function createDefaultContextMenuItems(localeOrMessages?: string | TimelineI18nMessages, overrides?: Partial<TimelineI18nMessages>): ContextMenuItem[];
533
540
  //#endregion
534
541
  //#region src/utils/performanceMonitor.d.ts
535
542
  interface PerformanceStats {
@@ -553,20 +560,24 @@ declare class Timeline {
553
560
  config: TimelineConfig;
554
561
  callbacks: TimelineCallbacks;
555
562
  state: TimelineState;
556
- private mouseHandler;
557
- private wheelHandler;
558
563
  private renderManager;
559
- private eventListeners;
564
+ private canvasController;
565
+ private interactionManager;
560
566
  private pluginManager;
567
+ private pluginController;
561
568
  private logger;
562
569
  private errorHandler;
563
570
  private stateManager;
564
571
  private eventIndexManager;
565
572
  private eventMutationService;
573
+ private trackManager;
574
+ private timeIndicatorController;
575
+ private viewportController;
566
576
  private guideLineService;
567
577
  private hitTestService;
568
578
  private changeScheduler;
569
- private currentThemePluginId;
579
+ private destroyed;
580
+ private destroyPromise;
570
581
  constructor(canvasId: string, options?: TimelineOptions);
571
582
  getCanvas(): HTMLCanvasElement;
572
583
  usePlugin(plugin: TimelinePlugin): Promise<boolean>;
@@ -574,7 +585,6 @@ declare class Timeline {
574
585
  isPluginLoaded(pluginName: string): boolean;
575
586
  removePlugin(pluginId: string): Promise<boolean>;
576
587
  setTheme(theme: "light" | "dark"): Promise<boolean>;
577
- private switchTheme;
578
588
  private init;
579
589
  getContentWidthForZoom(zoomLevel: number): number;
580
590
  hasHorizontalScrollbar(): boolean;
@@ -599,9 +609,7 @@ declare class Timeline {
599
609
  endIndexBatch(): void;
600
610
  invalidateIndexTrack(trackIndex: number): void;
601
611
  invalidateIndexAll(): void;
602
- private autoFitZoomToCanvas;
603
- private setupEventListeners;
604
- private setInitialCanvasSize;
612
+ private autoFitViewport;
605
613
  setCanvasSize(width: number, height: number): void;
606
614
  getCanvasLogicalHeight(): number;
607
615
  getCachedLogicalHeight(): number;
@@ -629,9 +637,6 @@ declare class Timeline {
629
637
  * - 使用节流的边界滚动而非每帧滚动
630
638
  */
631
639
  setTimeIndicatorDuringDrag(seconds: number): void;
632
- private _lastEdgeScrollTime;
633
- private scrollToTimeIndicatorThrottled;
634
- private scrollToTimeIndicator;
635
640
  zoom(factor: number): void;
636
641
  setZoomLevel(zoomLevel: number): boolean;
637
642
  getZoomLevel(): number;
@@ -657,10 +662,6 @@ declare class Timeline {
657
662
  eventIndex: number;
658
663
  edge: "left" | "right";
659
664
  } | null;
660
- private getEdgeScrollThrottle;
661
- private getEdgeScrollTriggerMargin;
662
- private getEdgeScrollViewportMargin;
663
- private resolveEdgeScrollValue;
664
665
  calculateGuideLines(fromTrackIndex: number, eventIndex: number, toTrackIndex: number, newStartTime: number, duration: number): Array<{
665
666
  time: number;
666
667
  type: "start" | "end";
@@ -686,10 +687,8 @@ declare class Timeline {
686
687
  eventIndex: number;
687
688
  } | null;
688
689
  isReadOnly(): boolean;
689
- destroy(): void;
690
+ destroy(): Promise<void>;
690
691
  private clearGuideLineCache;
691
- private getPluginId;
692
- private isThemePlugin;
693
692
  private redrawAfterPluginChange;
694
693
  }
695
694
  //#endregion
@@ -804,4 +803,4 @@ interface PerformanceProvider {
804
803
  getFPS: () => number;
805
804
  }
806
805
  //#endregion
807
- export { TimelineCallbacks as A, ZoomData as B, EventEditData as C, InteractionTarget as D, EventUpdateData as E, TimelineLocale as F, TimelineMessageParams as I, TimelineOptions as L, TimelineConfig as M, TimelineEvent as N, LoadDataFormat as O, TimelineI18nMessages as P, TimelineState as R, EventDeleteData as S, EventTextStyle as T, ContextMenuData as _, PluginLocalizedText as a, EventAddData as b, PluginType as c, TimelinePlugin as d, Timeline as f, getCurrentTime as g, formatTime as h, PluginContext as i, TimelineColors as j, TimeIndicatorMoveData as k, RenderLayer as l, createTimelineMessages as m, CoreRenderTarget as n, PluginMetadata as o, ChangeType as p, PluginAPI as r, PluginPriority as s, CoreLayerHook as t, RenderLayerPosition as u, ContextMenuItem as v, EventMoveData as w, EventClickData as x, ContextMenuStyle as y, Track as z };
806
+ export { LoadDataFormat as A, TimelineState as B, EventClickData as C, EventTextStyle as D, EventMoveData as E, TimelineEvent as F, ZoomData as H, TimelineI18nMessages as I, TimelineLocale as L, TimelineCallbacks as M, TimelineColors as N, EventUpdateData as O, TimelineConfig as P, TimelineMessageParams as R, EventAddData as S, EventEditData as T, Track as V, translateTimelineConfig as _, PluginLocalizedText as a, ContextMenuItem as b, PluginType as c, TimelinePlugin as d, Timeline as f, normalizeTimelineLocale as g, createTimelineMessages as h, PluginContext as i, TimeIndicatorMoveData as j, InteractionTarget as k, RenderLayer as l, createDefaultContextMenuItems as m, CoreRenderTarget as n, PluginMetadata as o, ChangeType as p, PluginAPI as r, PluginPriority as s, CoreLayerHook as t, RenderLayerPosition as u, translateTimelineMessage as v, EventDeleteData as w, ContextMenuStyle as x, ContextMenuData as y, TimelineOptions as z };
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "timeline-canvas",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "A powerful timeline component built with Canvas and TypeScript",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.mts",
8
8
  "type": "module",
9
9
  "scripts": {
10
- "build": "tsdown",
11
- "dev": "tsdown --watch",
10
+ "build": "vp pack",
11
+ "dev": "vp pack --watch --sourcemap --no-minify",
12
12
  "typecheck": "tsc -p tsconfig.json --noEmit",
13
- "lint": "oxlint src tests vitest.config.ts",
14
- "test": "vitest",
15
- "test:run": "vitest run",
16
- "test:coverage": "vitest run --coverage"
13
+ "lint": "vp lint src tests vite.config.ts",
14
+ "test": "vp test",
15
+ "test:watch": "vp test watch",
16
+ "test:run": "vp test run",
17
+ "test:coverage": "vp test run --coverage"
17
18
  },
18
19
  "keywords": [
19
20
  "timeline",
@@ -24,16 +25,16 @@
24
25
  ],
25
26
  "author": "sky <https://github.com/umbrella22>",
26
27
  "license": "MIT",
27
- "packageManager": "pnpm@10.18.1",
28
+ "packageManager": "pnpm@10.34.5",
28
29
  "devDependencies": {
29
- "@types/node": "^24.10.1",
30
- "@vitest/coverage-v8": "^4.1.2",
31
- "jsdom": "^29.0.1",
32
- "oxlint": "^1.43.0",
33
- "vitest": "^4.1.2"
30
+ "@types/node": "^26.4.1",
31
+ "@vitest/coverage-v8": "4.1.11",
32
+ "jsdom": "^30.0.1",
33
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
34
+ "vite-plus": "0.3.0"
34
35
  },
35
36
  "dependencies": {
36
- "immer": "^10.1.1"
37
+ "immer": "^11.1.18"
37
38
  },
38
39
  "files": [
39
40
  "dist",
@@ -1 +0,0 @@
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 +0,0 @@
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};
@@ -1 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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};
@@ -1 +0,0 @@
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 +0,0 @@
1
- var e=class{constructor(e=!1){this.metrics=new Map,this.startTimes=new Map,this.enabled=!1,this.maxSamples=100,this.enabled=e}enable(){this.enabled=!0}disable(){this.enabled=!1}startMeasurement(e){this.enabled&&this.startTimes.set(e,performance.now())}endMeasurement(e){if(!this.enabled)return;let t=this.startTimes.get(e);if(t===void 0)return;let n=performance.now()-t;this.metrics.has(e)||this.metrics.set(e,[]);let r=this.metrics.get(e);r.push(n),r.length>this.maxSamples&&r.shift(),this.startTimes.delete(e)}getAverage(e){let t=this.metrics.get(e);return!t||t.length===0?0:t.reduce((e,t)=>e+t,0)/t.length}getMin(e){let t=this.metrics.get(e);return!t||t.length===0?0:Math.min(...t)}getMax(e){let t=this.metrics.get(e);return!t||t.length===0?0:Math.max(...t)}getStats(e){let t=this.metrics.get(e);return!t||t.length===0?null:{average:this.getAverage(e),min:this.getMin(e),max:this.getMax(e),count:t.length,total:t.reduce((e,t)=>e+t,0)}}getAllStats(){let e=new Map;return this.metrics.forEach((t,n)=>{let r=this.getStats(n);r&&e.set(n,r)}),e}clear(){this.metrics.clear(),this.startTimes.clear()}clearMetric(e){this.metrics.delete(e),this.startTimes.delete(e)}getFPS(){let e=this.getStats(`draw`);return!e||e.average===0?0:1e3/e.average}};export{e as t};
File without changes