timeline-canvas 1.4.1 → 1.6.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.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/README_CN.md +3 -0
- package/dist/{ContextMenuPlugin-erWC3clR.d.mts → ContextMenuPlugin-BRv4YT-G.d.mts} +1 -2
- package/dist/{ContextMenuPlugin-DkjzERie.mjs → ContextMenuPlugin-Btbm1QEm.mjs} +1 -1
- package/dist/{DarkThemePlugin-DSeernWS.d.mts → DarkThemePlugin-DN2gKMxW.d.mts} +1 -2
- package/dist/{DarkThemePlugin-oE6DVEib.mjs → DarkThemePlugin-pFFtYjOV.mjs} +1 -1
- package/dist/{EventMediaPlugin-DpK2xquj.d.mts → EventMediaPlugin-B1YKwQ8_.d.mts} +1 -2
- package/dist/EventMediaPlugin-BCuSI5ww.mjs +1 -0
- package/dist/EventTooltipPlugin-0Dz25qie.mjs +1 -0
- package/dist/{EventTooltipPlugin-B2lXP9uu.d.mts → EventTooltipPlugin-CVvSszzY.d.mts} +1 -2
- package/dist/{LightThemePlugin-BigH_oWz.mjs → LightThemePlugin-BD4cbg_E.mjs} +1 -1
- package/dist/{LightThemePlugin-CXkW_Wpg.d.mts → LightThemePlugin-DOaW67ZR.d.mts} +1 -2
- package/dist/{PerformanceOverlayPlugin-CnfsbiMK.d.mts → PerformanceOverlayPlugin-BrIN19DR.d.mts} +1 -2
- package/dist/PerformanceOverlayPlugin-Cph1TMWd.mjs +1 -0
- package/dist/builtin-plugin/ContextMenuPlugin.d.mts +1 -1
- package/dist/builtin-plugin/ContextMenuPlugin.mjs +1 -1
- package/dist/builtin-plugin/DarkThemePlugin.d.mts +1 -1
- package/dist/builtin-plugin/DarkThemePlugin.mjs +1 -1
- package/dist/builtin-plugin/EventMediaPlugin.d.mts +1 -1
- package/dist/builtin-plugin/EventMediaPlugin.mjs +1 -1
- package/dist/builtin-plugin/EventTooltipPlugin.d.mts +1 -1
- package/dist/builtin-plugin/EventTooltipPlugin.mjs +1 -1
- package/dist/builtin-plugin/LightThemePlugin.d.mts +1 -1
- package/dist/builtin-plugin/LightThemePlugin.mjs +1 -1
- package/dist/builtin-plugin/MutexGuardPlugin.d.mts +1 -2
- package/dist/builtin-plugin/MutexGuardPlugin.mjs +1 -1
- package/dist/builtin-plugin/PerformanceOverlayPlugin.d.mts +1 -1
- package/dist/builtin-plugin/PerformanceOverlayPlugin.mjs +1 -1
- package/dist/index.d.mts +14 -9
- package/dist/index.mjs +1 -1
- package/dist/{types-Do4sfz9k.d.mts → types-KQ5C-I-e.d.mts} +500 -11
- package/package.json +17 -17
- package/dist/EventMediaPlugin-Co_Fr3CX.mjs +0 -1
- package/dist/EventTooltipPlugin-mbadM95i.mjs +0 -1
- package/dist/PerformanceOverlayPlugin-o5al1GSm.mjs +0 -1
- package/dist/performanceMonitor-Cb_v1gAo.mjs +0 -1
- /package/dist/{Logger-BTKQPGDj.mjs → Logger-BX6_sfV3.mjs} +0 -0
- /package/dist/{types-NnKZYB1U.mjs → types-DhRsiQBh.mjs} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
package/README.md
CHANGED
|
@@ -17,6 +17,9 @@ A powerful, high-performance timeline component built with HTML5 Canvas and Type
|
|
|
17
17
|
- 📏 **Smart Guides**: Alignment guides and snapping for precise event placement.
|
|
18
18
|
- ⏱️ **Time Indicator**: Draggable time head with snapping support.
|
|
19
19
|
- 🔌 **Plugin System**: Extensible architecture with built-in plugins for themes, context menus, and more.
|
|
20
|
+
- 🧭 **Resource scheduling (new in 1.6)**: optional `businessId` on events/tracks, strict atomic import/export (`loadScheduleData`/`exportScheduleData`), incremental upsert/patch/delete by business identity, a viewport snapshot subscription, and a unified `renderEventContent` hook covering normal, drag and resize phases.
|
|
21
|
+
- 📨 **Optional async editing protocol** (`scheduleEditing`): candidate preview, typed validation, single-commit settlement with server correction, unknown-result reconciliation and per-event edit state.
|
|
22
|
+
|
|
20
23
|
- 📝 **TypeScript**: Written in TypeScript with full type definitions.
|
|
21
24
|
|
|
22
25
|
## Installation
|
package/README_CN.md
CHANGED
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
- 📏 **智能辅助线**: 对齐辅助线和吸附功能,实现精确的事件放置。
|
|
18
18
|
- ⏱️ **时间指示器**: 可拖动的时间头,支持吸附。
|
|
19
19
|
- 🔌 **插件系统**: 可扩展架构,内置主题、右键菜单等插件。
|
|
20
|
+
- 🧭 **资源排程(1.6 新增)**: 事件/轨道可选 `businessId`,严格原子导入导出(`loadScheduleData`/`exportScheduleData`),按业务身份的增量 upsert/patch/删除,视口快照订阅,以及覆盖普通/拖动/拉伸阶段的统一 `renderEventContent` 内容入口。
|
|
21
|
+
- 📨 **可选异步编辑协议**(`scheduleEditing`):候选预览、typed 校验、单次提交结算与服务器修正、未知结果权威核对、单事件编辑状态查询。
|
|
22
|
+
|
|
20
23
|
- 📝 **TypeScript**: 使用 TypeScript 编写,提供完整的类型定义。
|
|
21
24
|
|
|
22
25
|
## 安装
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./Logger-
|
|
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 +1 @@
|
|
|
1
|
-
import"./types-
|
|
1
|
+
import"./types-DhRsiQBh.mjs";const e={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`},t={metadata:{name:`theme-dark`,version:`1.0.0`,description:`Dark theme for timeline`,descriptionI18n:{"zh-CN":`时间轴暗色主题`},type:`theme`},activate(t){t.config.colors={...t.config.colors,...e},t.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{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./types-DhRsiQBh.mjs";function e(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 t(e,t,n,r,i,a){return n+(e-t)*r*i-a}const n={en:{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`},"zh-CN":{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 渲染`}};function r(e){return e&&e.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`}function i(e=`en`,t={}){let i=r(e);return{...n[i],...t}}function a(e,t,n={}){return e[t].replace(/\{(\w+)\}/g,(e,t)=>t in n?String(n[t]):e)}function o(e,t,n={}){return a(e.messages||i(e.locale),t,n)}function s(e=`en`,t={}){let n=typeof e==`string`?i(e,t):e;return[{type:`edit`,name:n.contextMenuEdit},{type:`delete`,name:n.contextMenuDelete},{type:`export`,name:n.contextMenuExport}]}const c=i(`en`),l={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`},u={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},d={borderRadius:2,enableSelectionGlow:!1,selectionGlowBlur:10};s(c);const f={fontSize:14,fontFamily:`Arial, sans-serif`,fontWeight:`normal`,padding:8,itemHeight:32,borderRadius:6,borderWidth:1,minWidth:120},p={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:c,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:c.labelDurationPrefix,formatEventDuration:null,scale:null,scaleSplitCount:10,getScaleRender:null};var m=class{constructor(e=64){this.cache=new Map,this.totalBytes=0,this.hits=0,this.misses=0,this.maxBytes=e*1024*1024}get(e){let t=this.cache.get(e);if(!t){this.misses++;return}return this.cache.delete(e),this.cache.set(e,t),this.hits++,t.bitmap}set(e,t){let n=this.cache.get(e);n&&(n.bitmap.close(),this.totalBytes-=n.byteSize,this.cache.delete(e));let r=t.width*t.height*4;for(;this.totalBytes+r>this.maxBytes&&this.cache.size>0;){let e=this.cache.entries().next();if(e.done)break;let[t,n]=e.value;n.bitmap.close(),this.cache.delete(t),this.totalBytes-=n.byteSize}this.cache.set(e,{bitmap:t,byteSize:r}),this.totalBytes+=r}has(e){return this.cache.has(e)}invalidateEvent(e){let t=`${e}_`,n=[];for(let[e,r]of this.cache)e.startsWith(t)&&(r.bitmap.close(),this.totalBytes-=r.byteSize,n.push(e));for(let e of n)this.cache.delete(e)}clear(){for(let e of this.cache.values())e.bitmap.close();this.cache.clear(),this.totalBytes=0,this.hits=0,this.misses=0}getStats(){let e=this.hits+this.misses;return{size:this.cache.size,totalBytes:this.totalBytes,maxBytes:this.maxBytes,hitRate:e>0?this.hits/e:0,hits:this.hits,misses:this.misses}}getSizeMB(){return this.totalBytes/1048576}};function h(e,t,n,r,i){let a=e.get(t);if(a)return e.delete(t),e.set(t,a),a;let o=new Path2D,s=i/2,c=Math.max(1,Math.floor((i-2)/2)),l=n.length,u=Math.max(1,r-1);for(let e=0;e<r;e++){let t=Math.min(l-1,Math.max(0,Math.floor(e/u*l))),r=Math.max(-1,Math.min(1,n[t]))*c;o.moveTo(e,s-r),o.lineTo(e,s+r)}for(e.set(t,o);e.size>1024;){let t=e.keys().next();if(t.done)break;e.delete(t.value)}return o}function g(e,t){let n=`${t}_`;for(let t of e.keys())t.startsWith(n)&&e.delete(t)}function _(e,t,n,r,i,a,o,s,c,l){let u=e.get(n);if(u)return u;if(typeof OffscreenCanvas>`u`||i<=0||a<=0)return null;try{let u=Math.max(1,Math.ceil(i*o)),d=Math.max(1,Math.ceil(a*s)),f=new OffscreenCanvas(u,d),p=f.getContext(`2d`);if(!p)return null;p.scale(o,s),l&&(p.fillStyle=l,p.fillRect(0,0,i,a));let m=h(t,`${n}_path`,r,i,a);p.strokeStyle=c,p.lineWidth=1,p.stroke(m);let g=f.transferToImageBitmap();return e.set(n,g),g}catch(e){return console.debug(`[EventMediaPlugin] Failed to create waveform bitmap`,e),null}}function v(e,t){return e(t)}function y(e,t,n,r){let i=e.ids.get(t);if(i)return i;let a=e.nextId,o={cacheId:a,key:`event_media_${a}_${n}_${r}`};return e.nextId+=1,e.ids.set(t,o),o}function b(e,t,n,r,i){r.delete(e),r.set(e,t),i.delete(e),i.set(e,n)}function x(e,t,n,r){for(;e.size>1024;){let i=e.entries().next();if(i.done)break;let[a,o]=i.value;e.delete(a),t.delete(a),n.invalidateEvent(o.cacheId),g(r,o.cacheId)}}function S(){return{metadata:{name:`event-media`,version:`1.0.0`,description:`Render images and waveforms inside event blocks`,descriptionI18n:{"zh-CN":`在事件块内渲染图片和波形`},type:`render`},async activate(t){let n={ids:new WeakMap,nextId:0},r=new Map,i=new Map,a=new Map,o={active:!0},s=new Map,c=new Map,l=new m,u=new Map;t.api.setData(`eventMediaIdentityStore`,n),t.api.setData(`eventMediaImageCache`,r),t.api.setData(`eventMediaImageLoading`,i),t.api.setData(`eventMediaImageControllers`,a),t.api.setData(`eventMediaLifecycle`,o),t.api.setData(`eventMediaWaveCache`,s),t.api.setData(`eventMediaWaveStateCache`,c),t.api.setData(`eventMediaWaveformBitmapCache`,l),t.api.setData(`eventMediaWaveformPathCache`,u);let d=(n,r,i,s,c,d,f,p,m,S,C)=>{if(!o.active)return;let w=v(t.api.getData,`eventMediaImageCache`),T=v(t.api.getData,`eventMediaImageLoading`),E=v(t.api.getData,`eventMediaWaveCache`),D=v(t.api.getData,`eventMediaWaveStateCache`),O=v(t.api.getData,`eventMediaIdentityStore`),k=s.tracks[c].events[d];if(!k.media||!O)return;let A=p+S,j=i.eventBlockStyle.borderRadius,M=y(O,k,c,d);n.save();try{j>0?(e(n,f,A,m,C,j),n.clip()):(n.beginPath(),n.rect(f,A,m,C),n.clip());let r=k.media.images||[];if(r.length>0&&w&&T)for(let e of r){let r=`${M.key}_${e.src}`,i=w.get(r);if(!i&&!T.get(r)){let n=new AbortController;a.set(r,n);let i;i=fetch(e.src,{signal:n.signal}).then(e=>e.blob()).then(e=>createImageBitmap(e)).then(e=>{if(!o.active||T.get(r)!==i){e.close();return}return w.set(r,e),T.delete(r),a.delete(r),t.timeline.markDirty([`tracks`]),t.timeline.draw(),e}).catch(e=>{n.signal.aborted||console.debug(`[EventMediaPlugin] Failed to load event image`,e),T.get(r)===i&&(T.delete(r),a.delete(r))}),T.set(r,i)}if(i=w.get(r),i){let t=e.fit||`cover`,r=e.opacity===void 0?.35:e.opacity,a=m,o=C;if(t!==`stretch`){let e=i.width,n=i.height,r=t===`cover`?Math.max(m/e,C/n):Math.min(m/e,C/n);a=Math.max(1,Math.floor(e*r)),o=Math.max(1,Math.floor(n*r))}let s=f+(m-a)/2,c=A+(C-o)/2,l=n.globalAlpha;n.globalAlpha=r,n.drawImage(i,0,0,i.width,i.height,s,c,a,o),n.globalAlpha=l}}let i=k.media.waveform;if(i&&E&&D){let e=`${M.key}_wf`,t=D.get(e),r=E.get(e);(!t||!r||t.source!==i.data)&&(l.invalidateEvent(M.cacheId),g(u,M.cacheId),r=Array.isArray(i.data)?new Float32Array(i.data):i.data,t={cacheId:M.cacheId,source:i.data,revision:(t?.revision??0)+1}),b(e,t,r,D,E),x(D,E,l,u);let a=i.opacity===void 0?.5:i.opacity,o=n.globalAlpha;n.globalAlpha=a;let s=i.color||`#00A0FF`,c=n.getTransform(),d=Math.max(1,Math.hypot(c.a,c.b)),p=Math.max(1,Math.hypot(c.c,c.d)),v=Math.max(1,Math.ceil(m)),y=Math.max(1,Math.ceil(C)),S=`${v}_${y}_${Math.max(1,Math.ceil(v*d))}_${Math.max(1,Math.ceil(y*p))}_${d}_${p}_${s}_${i.backgroundColor||``}`;t.renderKey!==S&&(l.invalidateEvent(M.cacheId),g(u,M.cacheId),t.renderKey=S);let w=`${M.cacheId}_waveform_${t.revision}_${S}`,T=_(l,u,w,r,v,y,d,p,s,i.backgroundColor);if(T)n.drawImage(T,f,A,m,C);else{i.backgroundColor&&(n.fillStyle=i.backgroundColor,n.fillRect(f,A,m,C));let e=`${M.cacheId}_${t.revision}_${S}`,a=h(u,e,r,v,y);n.save(),n.translate(f,A),n.strokeStyle=s,n.lineWidth=1,n.stroke(a),n.restore()}n.globalAlpha=o}}finally{n.restore()}};t.api.registerEventHandler(`render:event:media`,d),t.api.setData(`eventMediaHandler`,d)},deactivate(e){let t=v(e.api.getData,`eventMediaLifecycle`);t&&(t.active=!1);let n=v(e.api.getData,`eventMediaHandler`);n&&e.api.unregisterEventHandler(`render:event:media`,n);let r=v(e.api.getData,`eventMediaImageCache`);if(r){for(let e of new Set(r.values()))e.close();r.clear()}let i=v(e.api.getData,`eventMediaImageControllers`);if(i){for(let e of i.values())e.abort();i.clear()}let a=v(e.api.getData,`eventMediaImageLoading`);a&&a.clear();let o=v(e.api.getData,`eventMediaWaveCache`);o&&o.clear();let s=v(e.api.getData,`eventMediaWaveStateCache`);s&&s.clear(),v(e.api.getData,`eventMediaWaveformBitmapCache`)?.clear(),v(e.api.getData,`eventMediaWaveformPathCache`)?.clear()}}}export{d as a,i as c,a as d,e as f,f as i,r as l,l as n,u as o,t as p,p as r,s,S as t,o as u};
|
|
@@ -0,0 +1 @@
|
|
|
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,5 +1,4 @@
|
|
|
1
|
-
import { d as TimelinePlugin } from "./types-
|
|
2
|
-
|
|
1
|
+
import { d as TimelinePlugin } from "./types-KQ5C-I-e.mjs";
|
|
3
2
|
//#region src/plugins/builtin/EventTooltipPlugin.d.ts
|
|
4
3
|
interface EventTooltipPluginOptions {
|
|
5
4
|
/** 自定义 HTML 模板函数,接收事件标题,返回 HTML 字符串。传入此参数将自动启用 HTML 渲染模式 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./types-
|
|
1
|
+
import"./types-DhRsiQBh.mjs";const e={canvasBackground:`#FFFFFF`,timelineBackground:`#FFFFFF`,trackBackground:`#FFFFFF`,trackBackgroundSelected:`rgba(63, 118, 252, 0.1)`,trackBackgroundOdd:`#FFFFFF`,trackBackgroundEven:`#F9FAFD`,timelineText:`#4B5563`,timelineGrid:`#E5E5E5`,timelineSubGrid:`#fff`,trackText:`#374151`,eventColors:[`rgba(63, 118, 252, 0.16)`],eventText:`#173B75`,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:`#006B75`,dragTimeReferenceLine:`#FFD700`,dragTimeReferenceLabel:`#795A00`,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`},t={metadata:{name:`theme-light`,version:`1.0.0`,description:`Light theme for timeline`,descriptionI18n:{"zh-CN":`时间轴亮色主题`},type:`theme`},activate(t){t.config.colors={...t.config.colors,...e},t.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{t};
|
|
@@ -0,0 +1 @@
|
|
|
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,2 +1,2 @@
|
|
|
1
|
-
import { t as ContextMenuPlugin } from "../ContextMenuPlugin-
|
|
1
|
+
import { t as ContextMenuPlugin } from "../ContextMenuPlugin-BRv4YT-G.mjs";
|
|
2
2
|
export { ContextMenuPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../ContextMenuPlugin-
|
|
1
|
+
import{t as e}from"../ContextMenuPlugin-Btbm1QEm.mjs";export{e as ContextMenuPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as DarkThemePlugin } from "../DarkThemePlugin-
|
|
1
|
+
import { t as DarkThemePlugin } from "../DarkThemePlugin-DN2gKMxW.mjs";
|
|
2
2
|
export { DarkThemePlugin as DarkTheme, DarkThemePlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../DarkThemePlugin-
|
|
1
|
+
import{t as e}from"../DarkThemePlugin-pFFtYjOV.mjs";export{e as DarkTheme,e as DarkThemePlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as EventMediaPlugin } from "../EventMediaPlugin-
|
|
1
|
+
import { t as EventMediaPlugin } from "../EventMediaPlugin-B1YKwQ8_.mjs";
|
|
2
2
|
export { EventMediaPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../EventMediaPlugin-
|
|
1
|
+
import{t as e}from"../EventMediaPlugin-BCuSI5ww.mjs";export{e as EventMediaPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as EventTooltipPlugin } from "../EventTooltipPlugin-
|
|
1
|
+
import { t as EventTooltipPlugin } from "../EventTooltipPlugin-CVvSszzY.mjs";
|
|
2
2
|
export { EventTooltipPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../EventTooltipPlugin-
|
|
1
|
+
import{t as e}from"../EventTooltipPlugin-0Dz25qie.mjs";export{e as EventTooltipPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as LightThemePlugin } from "../LightThemePlugin-
|
|
1
|
+
import { t as LightThemePlugin } from "../LightThemePlugin-DOaW67ZR.mjs";
|
|
2
2
|
export { LightThemePlugin as LightTheme, LightThemePlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../LightThemePlugin-
|
|
1
|
+
import{t as e}from"../LightThemePlugin-BD4cbg_E.mjs";export{e as LightTheme,e as LightThemePlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../types-
|
|
1
|
+
import"../types-DhRsiQBh.mjs";function e(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 t(){function t(t,n){if(!e(t))return!0;let{fromTrackIndex:r,fromEventIndex:i,newStartTime:a,duration:o}=t,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 n;return{metadata:{name:`MutexGuardPlugin`,version:`1.0.0`,description:`Disallow parallel existence of mutex-tagged events across tracks`,descriptionI18n:{"zh-CN":`禁止带互斥标签的事件在不同轨道上并行存在`},type:`extension`},activate(e){n=n=>t(n,e.state),e.api.registerEventHandler(`validate:event:move`,n)},deactivate(e){n&&=(e.api.unregisterEventHandler(`validate:event:move`,n),void 0)}}}export{t as MutexGuardPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PerformanceOverlayPlugin } from "../PerformanceOverlayPlugin-
|
|
1
|
+
import { t as PerformanceOverlayPlugin } from "../PerformanceOverlayPlugin-BrIN19DR.mjs";
|
|
2
2
|
export { PerformanceOverlayPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../PerformanceOverlayPlugin-
|
|
1
|
+
import{t as e}from"../PerformanceOverlayPlugin-Cph1TMWd.mjs";export{e as PerformanceOverlayPlugin};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { A as EventMoveData, B as
|
|
2
|
-
import { t as ContextMenuPlugin } from "./ContextMenuPlugin-
|
|
3
|
-
import { t as DarkThemePlugin } from "./DarkThemePlugin-
|
|
4
|
-
import { t as EventMediaPlugin } from "./EventMediaPlugin-
|
|
5
|
-
import { t as EventTooltipPlugin } from "./EventTooltipPlugin-
|
|
6
|
-
import { t as LightThemePlugin } from "./LightThemePlugin-
|
|
7
|
-
import { t as PerformanceOverlayPlugin } from "./PerformanceOverlayPlugin-
|
|
8
|
-
|
|
1
|
+
import { $ as ScheduleValidationResult, A as EventMoveData, B as ScheduleEditDraft, C as EventAddData, D as EventContentRenderContext, E as EventContentRect, F as ScheduleChange, G as ScheduleErrorCode, H as ScheduleEditState, I as ScheduleCommitResult, J as ScheduleEventPatch, K as ScheduleEventInput, L as ScheduleCommitStateData, M as EventUpdateData, N as InteractionTarget, O as EventDeleteData, P as LoadDataFormat, Q as ScheduleTrackInput, R as ScheduleCommitStateKind, S as ContextMenuStyle, T as EventContentPhase, U as ScheduleEditingOptions, V as ScheduleEditSnapshot, W as ScheduleError, X as SchedulePlacement, Y as ScheduleEventUpsert, Z as ScheduleResult, _ as translateTimelineConfig, a as PluginLocalizedText, at as TimelineI18nMessages, b as ContextMenuData, c as PluginType, ct as TimelineOptions, d as TimelinePlugin, dt as Track, et as TimeIndicatorMoveData, f as Timeline, ft as TrackRect, g as normalizeTimelineLocale, h as createTimelineMessages, i as PluginContext, it as TimelineEvent, j as EventTextStyle, k as EventEditData, l as RenderLayer, lt as TimelineState, m as createDefaultContextMenuItems, mt as ZoomData, n as CoreRenderTarget, nt as TimelineColors, o as PluginMetadata, ot as TimelineLocale, p as ChangeType, pt as ViewportListener, q as ScheduleEventLocation, r as PluginAPI, rt as TimelineConfig, s as PluginPriority, st as TimelineMessageParams, t as CoreLayerHook, tt as TimelineCallbacks, u as RenderLayerPosition, ut as TimelineViewportSnapshot, v as translateTimelineMessage, w as EventClickData, x as ContextMenuItem, y as BusinessId, z as ScheduleDataFormat } from "./types-KQ5C-I-e.mjs";
|
|
2
|
+
import { t as ContextMenuPlugin } from "./ContextMenuPlugin-BRv4YT-G.mjs";
|
|
3
|
+
import { t as DarkThemePlugin } from "./DarkThemePlugin-DN2gKMxW.mjs";
|
|
4
|
+
import { t as EventMediaPlugin } from "./EventMediaPlugin-B1YKwQ8_.mjs";
|
|
5
|
+
import { t as EventTooltipPlugin } from "./EventTooltipPlugin-CVvSszzY.mjs";
|
|
6
|
+
import { t as LightThemePlugin } from "./LightThemePlugin-DOaW67ZR.mjs";
|
|
7
|
+
import { t as PerformanceOverlayPlugin } from "./PerformanceOverlayPlugin-BrIN19DR.mjs";
|
|
8
|
+
//#region src/utils/time.d.ts
|
|
9
|
+
declare function formatTime(seconds: number, showSeconds?: boolean): string;
|
|
10
|
+
declare function getCurrentTime(): number;
|
|
11
|
+
declare function formatTimeRange(startTime: number, endTime: number): string;
|
|
12
|
+
declare function formatDuration(duration: number, label?: string): string;
|
|
13
|
+
//#endregion
|
|
9
14
|
//#region src/plugins/metadata.d.ts
|
|
10
15
|
declare function getPluginMetadataDescription(metadata: PluginMetadata, locale?: string): string;
|
|
11
16
|
//#endregion
|
|
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, createDefaultContextMenuItems, createTimelineMessages, formatDuration, formatTime, formatTimeRange, getCurrentTime, getPluginMetadataDescription, normalizeTimelineLocale, translateTimelineConfig, translateTimelineMessage };
|
|
17
|
+
export { type BusinessId, type ChangeType, type ContextMenuData, type ContextMenuItem, ContextMenuPlugin, type ContextMenuStyle, type CoreLayerHook, type CoreRenderTarget, DarkThemePlugin, type EventAddData, type EventClickData, type EventContentPhase, type EventContentRect, type EventContentRenderContext, 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 ScheduleChange, type ScheduleCommitResult, type ScheduleCommitStateData, type ScheduleCommitStateKind, type ScheduleDataFormat, type ScheduleEditDraft, type ScheduleEditSnapshot, type ScheduleEditState, type ScheduleEditingOptions, type ScheduleError, type ScheduleErrorCode, type ScheduleEventInput, type ScheduleEventLocation, type ScheduleEventPatch, type ScheduleEventUpsert, type SchedulePlacement, type ScheduleResult, type ScheduleTrackInput, type ScheduleValidationResult, type TimeIndicatorMoveData, Timeline, type TimelineCallbacks, type TimelineColors, type TimelineConfig, type TimelineEvent, type TimelineI18nMessages, type TimelineLocale, type TimelineMessageParams, type TimelineOptions, type TimelinePlugin, type TimelineState, type TimelineViewportSnapshot, type Track, type TrackRect, type ViewportListener, type ZoomData, createDefaultContextMenuItems, createTimelineMessages, formatDuration, formatTime, formatTimeRange, getCurrentTime, getPluginMetadataDescription, normalizeTimelineLocale, translateTimelineConfig, translateTimelineMessage };
|