timeline-canvas 1.6.0 → 1.6.1

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/dist/ContextMenuPlugin-BG1LlIHB.mjs +1 -0
  2. package/dist/{ContextMenuPlugin-BRv4YT-G.d.mts → ContextMenuPlugin-apgKHJko.d.mts} +1 -1
  3. package/dist/{DarkThemePlugin-DN2gKMxW.d.mts → DarkThemePlugin-BFzVkfT7.d.mts} +1 -1
  4. package/dist/{DarkThemePlugin-pFFtYjOV.mjs → DarkThemePlugin-Be9d-KQy.mjs} +1 -1
  5. package/dist/{EventMediaPlugin-BCuSI5ww.mjs → EventMediaPlugin-DtSgxxKt.mjs} +1 -1
  6. package/dist/{EventMediaPlugin-B1YKwQ8_.d.mts → EventMediaPlugin-bgTbuib5.d.mts} +1 -1
  7. package/dist/{EventTooltipPlugin-CVvSszzY.d.mts → EventTooltipPlugin-Cbp_ilBh.d.mts} +1 -1
  8. package/dist/EventTooltipPlugin-DaXsCDz6.mjs +1 -0
  9. package/dist/{LightThemePlugin-DOaW67ZR.d.mts → LightThemePlugin-C2kbid6J.d.mts} +1 -1
  10. package/dist/{LightThemePlugin-BD4cbg_E.mjs → LightThemePlugin-C_PaxYnb.mjs} +1 -1
  11. package/dist/Logger-CEaOmGZZ.mjs +1 -0
  12. package/dist/PerformanceOverlayPlugin-Cl76ioWj.mjs +1 -0
  13. package/dist/{PerformanceOverlayPlugin-BrIN19DR.d.mts → PerformanceOverlayPlugin-oAGE20gZ.d.mts} +1 -1
  14. package/dist/builtin-plugin/ContextMenuPlugin.d.mts +1 -1
  15. package/dist/builtin-plugin/ContextMenuPlugin.mjs +1 -1
  16. package/dist/builtin-plugin/DarkThemePlugin.d.mts +1 -1
  17. package/dist/builtin-plugin/DarkThemePlugin.mjs +1 -1
  18. package/dist/builtin-plugin/EventMediaPlugin.d.mts +1 -1
  19. package/dist/builtin-plugin/EventMediaPlugin.mjs +1 -1
  20. package/dist/builtin-plugin/EventTooltipPlugin.d.mts +1 -1
  21. package/dist/builtin-plugin/EventTooltipPlugin.mjs +1 -1
  22. package/dist/builtin-plugin/LightThemePlugin.d.mts +1 -1
  23. package/dist/builtin-plugin/LightThemePlugin.mjs +1 -1
  24. package/dist/builtin-plugin/MutexGuardPlugin.d.mts +3 -4
  25. package/dist/builtin-plugin/MutexGuardPlugin.mjs +1 -1
  26. package/dist/builtin-plugin/PerformanceOverlayPlugin.d.mts +1 -1
  27. package/dist/builtin-plugin/PerformanceOverlayPlugin.mjs +1 -1
  28. package/dist/index.d.mts +13 -13
  29. package/dist/index.mjs +1 -1
  30. package/dist/{types-KQ5C-I-e.d.mts → types-BQzXZLxo.d.mts} +17 -9
  31. package/dist/types-C-Fl4OGV.mjs +1 -0
  32. package/package.json +21 -16
  33. package/LICENSE +0 -21
  34. package/dist/ContextMenuPlugin-Btbm1QEm.mjs +0 -1
  35. package/dist/EventTooltipPlugin-0Dz25qie.mjs +0 -1
  36. package/dist/Logger-BX6_sfV3.mjs +0 -1
  37. package/dist/PerformanceOverlayPlugin-Cph1TMWd.mjs +0 -1
  38. package/dist/types-DhRsiQBh.mjs +0 -1
@@ -827,6 +827,7 @@ interface EditTransaction {
827
827
  action: "move" | "resize";
828
828
  resizeEdge?: "left" | "right";
829
829
  before: ScheduleEditSnapshot;
830
+ source: TimelineEvent;
830
831
  beforeTrackIndex: number;
831
832
  beforeEventIndex: number;
832
833
  draft: SchedulePlacement;
@@ -883,6 +884,7 @@ declare class EditTransactionController {
883
884
  updateDraft(businessId: BusinessId, placement: SchedulePlacement, targetTrackIndex: number): void;
884
885
  /** 当前事务(若只要求未终态) */
885
886
  getTransaction(businessId: BusinessId): EditTransaction | undefined;
887
+ matchesSource(businessId: BusinessId): boolean;
886
888
  /** 用最终候选构建 ScheduleChange(after 为独立快照) */
887
889
  buildChange(businessId: BusinessId): ScheduleChange | null;
888
890
  /** 记录最后一次候选评估无效:提交时丢弃编辑而不是隐式提交上一个有效位置 */
@@ -935,6 +937,14 @@ declare class EditTransactionController {
935
937
  type ChangeType = "events:add" | "events:update" | "events:delete" | "events:move" | "events:split" | "tracks:add" | "tracks:update" | "tracks:remove" | "timeIndicator:move" | "timeIndicator:drag" | "scroll:x" | "scroll:y" | "zoom:change" | "selection:change" | "highlight:change" | "canvas:resize" | "data:load" | "theme:change" | "interaction:hover" | "interaction:contextMenu" | "interaction:splitLine" | "config:debug" | "config:timeIndicator" | "config:endTime" | "config:readOnly";
936
938
  //#endregion
937
939
  //#region src/core/Timeline.d.ts
940
+ interface ScheduleCandidate {
941
+ eventBusinessId: BusinessId;
942
+ fromTrackIndex: number;
943
+ fromEventIndex: number;
944
+ toTrackIndex: number;
945
+ startTime: number;
946
+ endTime: number;
947
+ }
938
948
  declare class Timeline {
939
949
  private canvas;
940
950
  private ctx;
@@ -966,6 +976,7 @@ declare class Timeline {
966
976
  private destroyed;
967
977
  /** 数据集代数:整批权威替换(loadData/loadScheduleData)成功时自增,供提交协调器检测 accepted 通知内的重入刷新 */
968
978
  private datasetEpoch;
979
+ private readonly finalizingEdits;
969
980
  private destroyPromise;
970
981
  constructor(canvasId: string, options?: TimelineOptions);
971
982
  getCanvas(): HTMLCanvasElement;
@@ -1019,6 +1030,8 @@ declare class Timeline {
1019
1030
  addTrack(): void;
1020
1031
  removeTrack(): void;
1021
1032
  autoRemoveEmptyLastTrack(): void;
1033
+ private lastTrackReserved;
1034
+ private invalidateTrackStructure;
1022
1035
  addEvent(trackIndex: number, startTime: number, endTime: number, title: string, description?: string, customData?: Record<string, unknown>, readonly?: boolean): void;
1023
1036
  updateEvent(trackIndex: number, eventIndex: number, updates: Partial<TimelineEvent>): boolean;
1024
1037
  updateEventData(trackIndex: number, eventIndex: number, eventData: {
@@ -1047,21 +1060,16 @@ declare class Timeline {
1047
1060
  * 编辑候选的核心同步校验(typed):只做本地约束,业务校验由
1048
1061
  * scheduleEditing.validate 在提交前单独执行,二者不允许互相替代。
1049
1062
  */
1050
- validateScheduleEditCandidate(params: {
1051
- eventBusinessId: BusinessId;
1052
- fromTrackIndex: number;
1053
- fromEventIndex: number;
1054
- toTrackIndex: number;
1055
- startTime: number;
1056
- endTime: number;
1057
- }, options?: {
1063
+ validateScheduleEditCandidate(params: ScheduleCandidate, options?: {
1058
1064
  forPublish?: boolean;
1059
1065
  }): ScheduleValidationResult;
1066
+ private validateScheduleFacts;
1060
1067
  /**
1061
1068
  * 落点提交:最终候选校验 → 业务 validate → 通知 pending → 调用一次 onBeforeCommit。
1062
1069
  * 返回 false 表示未发起提交(typed 原因已通过状态回调/状态文本给出)。
1063
1070
  */
1064
1071
  commitScheduleEdit(businessId: BusinessId): boolean;
1072
+ private finalizeScheduleEdit;
1065
1073
  /** 接受结果的原子发布:身份/资源/时间/重叠(排除自身与预约)逐项校验后落盘 */
1066
1074
  private publishAcceptedPlacement;
1067
1075
  /** 旧成功回调:确认后发送一次(move→onEventMove / resize→onEventUpdate) */
@@ -1290,4 +1298,4 @@ interface PerformanceProvider {
1290
1298
  getFPS: () => number;
1291
1299
  }
1292
1300
  //#endregion
1293
- export { ScheduleValidationResult as $, EventMoveData as A, ScheduleEditDraft as B, EventAddData as C, EventContentRenderContext as D, EventContentRect as E, ScheduleChange as F, ScheduleErrorCode as G, ScheduleEditState as H, ScheduleCommitResult as I, ScheduleEventPatch as J, ScheduleEventInput as K, ScheduleCommitStateData as L, EventUpdateData as M, InteractionTarget as N, EventDeleteData as O, LoadDataFormat as P, ScheduleTrackInput as Q, ScheduleCommitStateKind as R, ContextMenuStyle as S, EventContentPhase as T, ScheduleEditingOptions as U, ScheduleEditSnapshot as V, ScheduleError as W, SchedulePlacement as X, ScheduleEventUpsert as Y, ScheduleResult as Z, translateTimelineConfig as _, PluginLocalizedText as a, TimelineI18nMessages as at, ContextMenuData as b, PluginType as c, TimelineOptions as ct, TimelinePlugin as d, Track as dt, TimeIndicatorMoveData as et, Timeline as f, TrackRect as ft, normalizeTimelineLocale as g, createTimelineMessages as h, PluginContext as i, TimelineEvent as it, EventTextStyle as j, EventEditData as k, RenderLayer as l, TimelineState as lt, createDefaultContextMenuItems as m, ZoomData as mt, CoreRenderTarget as n, TimelineColors as nt, PluginMetadata as o, TimelineLocale as ot, ChangeType as p, ViewportListener as pt, ScheduleEventLocation as q, PluginAPI as r, TimelineConfig as rt, PluginPriority as s, TimelineMessageParams as st, CoreLayerHook as t, TimelineCallbacks as tt, RenderLayerPosition as u, TimelineViewportSnapshot as ut, translateTimelineMessage as v, EventClickData as w, ContextMenuItem as x, BusinessId as y, ScheduleDataFormat as z };
1301
+ export { ScheduleResult as $, EventDeleteData as A, ScheduleCommitStateKind as B, ContextMenuStyle as C, EventContentPhase as D, EventClickData as E, InteractionTarget as F, ScheduleEditingOptions as G, ScheduleEditDraft as H, LoadDataFormat as I, ScheduleEventInput as J, ScheduleError as K, ScheduleChange as L, EventMoveData as M, EventTextStyle as N, EventContentRect as O, EventUpdateData as P, SchedulePlacement as Q, ScheduleCommitResult as R, ContextMenuItem as S, EventBlockStyle as T, ScheduleEditSnapshot as U, ScheduleDataFormat as V, ScheduleEditState as W, ScheduleEventPatch as X, ScheduleEventLocation as Y, ScheduleEventUpsert as Z, normalizeTimelineLocale as _, PluginLocalizedText as a, TimelineConfig as at, BusinessId as b, PluginType as c, TimelineLocale as ct, TimelinePlugin as d, TimelineState as dt, ScheduleTrackInput as et, Timeline as f, TimelineViewportSnapshot as ft, createTimelineMessages as g, ZoomData as gt, createDefaultContextMenuItems as h, ViewportListener as ht, PluginContext as i, TimelineColors as it, EventEditData as j, EventContentRenderContext as k, RenderLayer as l, TimelineMessageParams as lt, TimelineMessageKey as m, TrackRect as mt, CoreRenderTarget as n, TimeIndicatorMoveData as nt, PluginMetadata as o, TimelineEvent as ot, ChangeType as p, Track as pt, ScheduleErrorCode as q, PluginAPI as r, TimelineCallbacks as rt, PluginPriority as s, TimelineI18nMessages as st, CoreLayerHook as t, ScheduleValidationResult as tt, RenderLayerPosition as u, TimelineOptions as ut, translateTimelineConfig as v, EventAddData as w, ContextMenuData as x, translateTimelineMessage as y, ScheduleCommitStateData as z };
@@ -0,0 +1 @@
1
+ let e=/* @__PURE__ */ function(e){return e.RENDER=`render`,e.EVENT_HANDLER=`event_handler`,e.DATA_SOURCE=`data_source`,e.THEME=`theme`,e.TOOL=`tool`,e.EXTENSION=`extension`,e}({}),t=/* @__PURE__ */ function(e){return e[e.LOW=0]=`LOW`,e[e.NORMAL=50]=`NORMAL`,e[e.HIGH=100]=`HIGH`,e[e.CRITICAL=200]=`CRITICAL`,e}({});export{e as n,t};
package/package.json CHANGED
@@ -1,11 +1,21 @@
1
1
  {
2
2
  "name": "timeline-canvas",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
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
+ "scripts": {
10
+ "build": "vp pack",
11
+ "dev": "vp pack --watch --sourcemap --no-minify",
12
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.contract-tests.json --noEmit",
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"
18
+ },
9
19
  "keywords": [
10
20
  "timeline",
11
21
  "canvas",
@@ -15,12 +25,17 @@
15
25
  ],
16
26
  "author": "sky <https://github.com/umbrella22>",
17
27
  "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/umbrella22/timeline-canvas.git",
31
+ "directory": "packages/timeline"
32
+ },
33
+ "packageManager": "pnpm@10.34.5",
18
34
  "devDependencies": {
19
- "@types/node": "^26.4.1",
35
+ "@types/node": "^26.6.2",
20
36
  "@vitest/coverage-v8": "4.1.11",
21
- "jsdom": "^30.0.1",
22
- "vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
23
- "vite-plus": "0.3.0"
37
+ "jsdom": "^30.1.1",
38
+ "vite-plus": "0.3.3"
24
39
  },
25
40
  "dependencies": {
26
41
  "immer": "^11.1.18"
@@ -39,15 +54,5 @@
39
54
  "types": "./dist/builtin-plugin/*.d.mts",
40
55
  "import": "./dist/builtin-plugin/*.mjs"
41
56
  }
42
- },
43
- "scripts": {
44
- "build": "vp pack",
45
- "dev": "vp pack --watch --sourcemap --no-minify",
46
- "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.contract-tests.json --noEmit",
47
- "lint": "vp lint src tests vite.config.ts",
48
- "test": "vp test",
49
- "test:watch": "vp test watch",
50
- "test:run": "vp test run",
51
- "test:coverage": "vp test run --coverage"
52
57
  }
53
- }
58
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Sky
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1 +0,0 @@
1
- import{i as e}from"./Logger-BX6_sfV3.mjs";import"./types-DhRsiQBh.mjs";const t=e(`ContextMenuPlugin`);function n(e,t){return e(t)}function r(e={}){return{metadata:{name:`context-menu`,version:`1.0.0`,description:`Context menu as plugin, supports HTML takeover`,descriptionI18n:{"zh-CN":`插件化右键菜单,支持 HTML 接管渲染`},type:`extension`},activate(r){let i=r.config&&r.config.contextMenuHtml||void 0,a=e.htmlTemplate||(typeof i==`string`?i:void 0),o=!!a;o&&(!a||a.trim()===``)&&(t.warn(r.timeline.t(`warningEmptyHtmlTemplateFallback`)),o=!1),r.api.registerRenderLayer({name:`context-menu-overlay`,position:`overlay`,render(e,t,i,s){if(!i.enableContextMenu||!s.contextMenuVisible||!s.contextMenuEvent){let e=n(r.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=n(r.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,r.api.setData(`contextMenuTextWidthCache`,v);let b=g,x=i.contextMenuItems.length*l+c*2,S=r.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 t=n(r.api.getData,`contextMenuContainer`)||null;if(!t){t=document.createElement(`div`),t.style.position=`absolute`,t.style.zIndex=`1000`,t.style.boxShadow=`0 2px 10px rgba(0,0,0,0.3)`,t.style.border=`${d}px solid ${i.colors.contextMenuBorder}`,t.style.borderRadius=`${u}px`,t.style.font=`${h} ${p}px ${m}`,t.style.background=i.colors.contextMenuBackground,t.style.color=i.colors.contextMenuText;let e=r.timeline.getCanvas().parentElement||document.body;e.style.position=e.style.position||`relative`,e.appendChild(t),r.api.setData(`contextMenuContainer`,t)}if(t.style.display=`block`,t.style.left=`${C}px`,t.style.top=`${w}px`,t.style.width=`${b}px`,t.style.height=`${x}px`,a)t.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>`}t.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=n(e.api.getData,`contextMenuContainer`)||null;t&&t.parentElement&&t.parentElement.removeChild(t)},destroy(e){let t=n(e.api.getData,`contextMenuContainer`)||null;t&&t.parentElement&&t.parentElement.removeChild(t)}}}export{r as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./Logger-BX6_sfV3.mjs";import"./types-DhRsiQBh.mjs";const t=e(`EventTooltipPlugin`);function n(e,t){return e(t)}function r(e={}){let{htmlTemplate:r,showDelay:i=300,maxWidth:a=300,padding:o=8,borderRadius:s=4,backgroundColor:c=`#333`,textColor:l=`#fff`,borderColor:u=`#555`,fontSize:d=12,fontFamily:f=`Arial, sans-serif`}=e,p={visible:!1,title:``,x:0,y:0,trackIndex:-1,eventIndex:-1},m=null,h=null,g=null,_=null,v=()=>{m&&=(clearTimeout(m),null),h!==null&&(cancelAnimationFrame(h),h=null),g=null,_=null};function y(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:`extension`},activate(e){let b=e.timeline.getCanvas(),x=t=>{let n=b.getBoundingClientRect(),r=t.clientX-n.left,a=t.clientY-n.top,o=e.config,s=e.state,c=e.timeline.getEventAtPosition(r,a);if(c){let{trackIndex:t,eventIndex:n}=c,l=s.tracks[t]?.events[n];if(!l){C();return}if(_&&_.trackIndex===t&&_.eventIndex===n&&p.visible){p.x=r,p.y=a,e.timeline.draw();return}_={trackIndex:t,eventIndex:n},m&&=(clearTimeout(m),null);let u=l.duration*o.secondWidth*s.zoomLevel-20,d=b.getContext(`2d`);if(!d)return;let f=o.eventTextStyle,h=f.titleFontSize===`auto`?Math.max(10,Math.min(14,o.trackHeight*.175)):f.titleFontSize;d.font=`${f.titleFontWeight} ${h}px ${f.titleFontFamily}`,y(d,l.title,u)?m=setTimeout(()=>{p={visible:!0,title:l.title,x:r,y:a,trackIndex:t,eventIndex:n},e.timeline.draw()},i):C()}else C()},S=e=>{g=e,h===null&&(h=requestAnimationFrame(()=>{h=null,g&&=(x(g),null)}))},C=()=>{m&&=(clearTimeout(m),null),_=null,p.visible&&(p.visible=!1,e.timeline.draw())},w=()=>{v(),p.visible&&(p.visible=!1,e.timeline.draw())};b.addEventListener(`mousemove`,S),b.addEventListener(`mouseleave`,w),e.api.setData(`tooltipMouseMoveHandler`,S),e.api.setData(`tooltipMouseLeaveHandler`,w),e.api.registerRenderLayer({name:`event-tooltip-overlay`,position:`overlay`,render(i,m,h,g){if(!p.visible||!p.title){let t=n(e.api.getData,`tooltipContainer`)||null;t&&(t.style.display=`none`);return}let _=e.timeline.getCanvas().getBoundingClientRect(),v=p.x,y=p.y-10;i.save(),i.font=`${d}px ${f}`;let b=p.title.split(``),x=[],S=``;for(let e of b){let t=S+e;i.measureText(t).width>a-o*2?S?(x.push(S),S=e):x.push(e):S=t}S&&x.push(S);let C=0;for(let e of x){let t=i.measureText(e).width;C=Math.max(C,t)}C=Math.min(C+o*2,a);let w=d*1.4,T=x.length*w+o*2;if(y-=T,v+C>_.width&&(v=_.width-C-5),v<5&&(v=5),y<5&&(y=p.y+20),r){let m=r(p.title);if(!m||m.trim()===``)t.warn(e.timeline.t(`warningEmptyTooltipTemplateFallback`));else{let t=n(e.api.getData,`tooltipContainer`)||null;if(!t){t=document.createElement(`div`),t.style.position=`absolute`,t.style.zIndex=`1001`,t.style.pointerEvents=`none`,t.style.boxShadow=`0 2px 8px rgba(0,0,0,0.3)`,t.style.border=`1px solid ${u}`,t.style.borderRadius=`${s}px`,t.style.padding=`${o}px`,t.style.fontSize=`${d}px`,t.style.fontFamily=f,t.style.backgroundColor=c,t.style.color=l,t.style.maxWidth=`${a}px`,t.style.wordWrap=`break-word`,t.style.whiteSpace=`pre-wrap`;let n=e.timeline.getCanvas().parentElement||document.body;n.style.position=n.style.position||`relative`,n.appendChild(t),e.api.setData(`tooltipContainer`,t)}t.style.display=`block`,t.style.left=`${v}px`,t.style.top=`${y}px`,t.innerHTML=m,i.restore();return}}if(i.shadowColor=`rgba(0, 0, 0, 0.3)`,i.shadowBlur=8,i.shadowOffsetX=0,i.shadowOffsetY=2,i.fillStyle=c,i.beginPath(),i.roundRect)i.roundRect(v,y,C,T,s);else{let e=v,t=y,n=C,r=T,a=s;i.moveTo(e+a,t),i.lineTo(e+n-a,t),i.quadraticCurveTo(e+n,t,e+n,t+a),i.lineTo(e+n,t+r-a),i.quadraticCurveTo(e+n,t+r,e+n-a,t+r),i.lineTo(e+a,t+r),i.quadraticCurveTo(e,t+r,e,t+r-a),i.lineTo(e,t+a),i.quadraticCurveTo(e,t,e+a,t)}i.fill(),i.shadowColor=`transparent`,i.shadowBlur=0,i.strokeStyle=u,i.lineWidth=1,i.stroke(),i.fillStyle=l,i.font=`${d}px ${f}`,i.textAlign=`left`,i.textBaseline=`top`;for(let e=0;e<x.length;e++)i.fillText(x[e],v+o,y+o+e*w);i.restore()}})},deactivate(e){let t=e.timeline.getCanvas(),r=n(e.api.getData,`tooltipMouseMoveHandler`),i=n(e.api.getData,`tooltipMouseLeaveHandler`);r&&t.removeEventListener(`mousemove`,r),i&&t.removeEventListener(`mouseleave`,i),v(),p.visible=!1,e.api.unregisterRenderLayer(`event-tooltip-overlay`);let a=n(e.api.getData,`tooltipContainer`)||null;a&&a.parentElement&&a.parentElement.removeChild(a)},destroy(e){let t=n(e.api.getData,`tooltipContainer`)||null;t&&t.parentElement&&t.parentElement.removeChild(t),v(),p.visible=!1}}}export{r as t};
@@ -1 +0,0 @@
1
- const e={pipeline:`color: #2196F3; font-weight: bold;`,pipelineLayer:`color: #64B5F6;`,pipelineSkip:`color: #90A4AE;`,stateMachine:`color: #4CAF50; font-weight: bold;`,stateTransition:`color: #81C784;`,stateEnter:`color: #A5D6A7;`,stateExit:`color: #C8E6C9;`,eventRender:`color: #FF9800; font-weight: bold;`,eventInfo:`color: #FFB74D;`,eventSkip:`color: #FFCC80;`,dataUpdate:`color: #9C27B0; font-weight: bold;`,dataInfo:`color: #BA68C8;`,scheduler:`color: #00BCD4; font-weight: bold;`,schedulerInfo:`color: #4DD0E1;`,plugin:`color: #E91E63; font-weight: bold;`,pluginInfo:`color: #F48FB1;`,reset:`color: inherit; font-weight: normal;`},t={enabled:!0,level:`info`},n=new Map;var r=class{constructor(e){this.enabled=e?.enabled??!0,this.level=e?.level??`info`,this.prefix=e?.prefix??`Timeline`,this.useGlobalConfig=e?.useGlobalConfig??!0}setEnabled(e){this.enabled=e}setLevel(e){this.level=e}setPrefix(e){this.prefix=e}rank(e){switch(e){case`debug`:return 10;case`info`:return 20;case`warn`:return 30;case`error`:return 40}}shouldLog(e){return this.useGlobalConfig?t.enabled?this.rank(e)>=this.rank(t.level):!1:this.enabled&&this.rank(e)>=this.rank(this.level)}debug(...e){this.shouldLog(`debug`)&&console.debug(`[${this.prefix}]`,...e)}debugStyled(e,t,...n){this.shouldLog(`debug`)&&console.debug(`%c[${this.prefix}] ${t}`,e,...n)}info(...e){this.shouldLog(`info`)&&console.info(`[${this.prefix}]`,...e)}warn(...e){this.shouldLog(`warn`)&&console.warn(`[${this.prefix}]`,...e)}error(...e){this.shouldLog(`error`)&&console.error(`[${this.prefix}]`,...e)}};function i(e){let t=n.get(e);return t||(t=new r({prefix:e,useGlobalConfig:!0}),n.set(e,t)),t}function a(e){e.enabled!==void 0&&(t.enabled=e.enabled),e.level!==void 0&&(t.level=e.level)}export{i,r as n,a as r,e as t};
@@ -1 +0,0 @@
1
- import"./types-DhRsiQBh.mjs";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}};const t={metadata:{name:`performance-overlay`,version:`1.0.0`,description:`Draw performance metrics overlay`,descriptionI18n:{"zh-CN":`绘制性能指标叠加层`},type:`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=()=>!!(t.config.enablePerformanceMonitor||t.config.debug),o=e=>{if(!a()){t.api.setData(`perfOverlayDragging`,!1);return}let n=i.getBoundingClientRect(),r=e.clientX-n.left,o=e.clientY-n.top,s=t.api.getData(`perfOverlaySize`),c=t.api.getData(`perfOverlayPos`)||{x:10,y:10};s&&r>=c.x&&r<=c.x+s.width&&o>=c.y&&o<=c.y+s.height&&(t.api.setData(`perfOverlayDragging`,!0),t.api.setData(`perfOverlayOffset`,{x:r-c.x,y:o-c.y}),e.stopImmediatePropagation(),e.preventDefault())},s=e=>{if(!a()){t.api.setData(`perfOverlayDragging`,!1);return}if(!t.api.getData(`perfOverlayDragging`))return;let n=i.getBoundingClientRect(),r=e.clientX-n.left,o=e.clientY-n.top,s=t.api.getData(`perfOverlayOffset`)||{x:0,y:0},c=t.api.getData(`perfOverlaySize`)||{width:0,height:0},l=r-s.x,u=o-s.y;l=Math.max(0,Math.min(n.width-c.width,l)),u=Math.max(0,Math.min(n.height-c.height,u)),t.api.setData(`perfOverlayPos`,{x:l,y:u}),t.timeline.markDirty([`overlay`]),t.timeline.draw(),e.stopImmediatePropagation(),e.preventDefault()},c=e=>{t.api.getData(`perfOverlayDragging`)&&t.api.setData(`perfOverlayDragging`,!1)};i.addEventListener(`mousedown`,o,{capture:!0}),i.addEventListener(`mousemove`,s,{capture:!0}),window.addEventListener(`mouseup`,c,{capture:!0}),t.api.setData(`perfOverlayListeners`,{onMouseDown:o,onMouseMove:s,onMouseUp:c}),t.api.registerRenderLayer({name:`performance-overlay`,position:`overlay`,render(e,r){let i=t.api.getData(`perfMonitor`),o=a();if(i){if(o)i.enable();else{i.disable(),i.clear(),t.api.setData(`perfOverlaySize`,void 0),t.api.setData(`perfOverlayDragging`,!1);return}}else if(!o)return;let s=t.api.getPerformanceStats(),c=r.width<240,l=c?8:15,u=c?16:20,d=c?20:25,f=t.api.getFPS(),p=Array.from(s.entries()),m=Math.min(280,r.width,Math.max(100,r.width*.8)),h=[`background`,`tracks`,`timeline`,`interaction`,`guideLines`,`scrollbar`,`overlay`,`dragPreview`],g=t.timeline.getLastLayerTimes?t.timeline.getLastLayerTimes():void 0,_=g?h.filter(e=>g[e]!==void 0).length:0,v=g?1+_:0,y=1+(s.size===0?1:p.length)+v,b=Math.min(r.height,Math.max(40,r.height-20)),x=Math.max(1,Math.min(y,Math.floor((b-d-l*2)/u))),S=Math.min(b,d+x*u+l*2),C=t.api.getData(`perfOverlayPos`)||{x:10,y:10},w={x:Math.max(0,Math.min(r.width-m,C.x)),y:Math.max(0,Math.min(r.height-S,C.y))};t.api.setData(`perfOverlayPos`,w),t.api.setData(`perfOverlaySize`,{width:m,height:S}),e.save(),e.beginPath(),e.rect(w.x,w.y,m,S),e.clip(),e.fillStyle=`rgba(0, 0, 0, 0.8)`,e.fillRect(w.x,w.y,m,S),e.strokeStyle=`rgba(100, 255, 100, 0.6)`,e.lineWidth=2,e.strokeRect(w.x,w.y,m,S),e.fillStyle=`#00FF00`,e.font=`bold ${c?12:16}px monospace`,e.textAlign=`left`,e.fillText(t.timeline.t(`overlayPerformanceMonitor`),w.x+10,w.y+20);let T=w.y+20+d;e.fillStyle=f>=55?`#00FF00`:f>=30?`#FFFF00`:`#FF0000`,e.font=`bold ${c?11:14}px monospace`,e.fillText(t.timeline.t(`overlayFps`,{value:f.toFixed(1)}),w.x+10,T),e.font=`${c?10:12}px monospace`,T+=u;let E=()=>T<=w.y+S-l;if(g&&E()){e.fillStyle=`#00FFFF`,e.font=`bold ${c?10:12}px monospace`,e.fillText(t.timeline.t(`overlayLayerTimesMs`),w.x+10,T),T+=u,e.font=`${c?10:12}px monospace`,e.fillStyle=`#FFFFFF`;for(let r of h)g[r]!==void 0&&E()&&(e.fillText(`${t.timeline.t(n[r]||`overlayLayerOverlay`)}: ${g[r].toFixed(2)}`,w.x+10,T),T+=u)}s.size===0&&E()?(e.fillStyle=`#FFFFFF`,e.fillText(t.timeline.t(`overlayCollecting`),w.x+10,T),T+=u):p.forEach(([t,n])=>{if(!E())return;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,w.x+10,T),T+=u}),e.restore()}})},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{t};
@@ -1 +0,0 @@
1
- let e=function(e){return e.RENDER=`render`,e.EVENT_HANDLER=`event_handler`,e.DATA_SOURCE=`data_source`,e.THEME=`theme`,e.TOOL=`tool`,e.EXTENSION=`extension`,e}({}),t=function(e){return e[e.LOW=0]=`LOW`,e[e.NORMAL=50]=`NORMAL`,e[e.HIGH=100]=`HIGH`,e[e.CRITICAL=200]=`CRITICAL`,e}({});export{e as n,t};