@visactor/vrender-core 0.19.0-alpha.1 → 0.19.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 (181) hide show
  1. package/cjs/common/text.d.ts +3 -2
  2. package/cjs/common/text.js +20 -4
  3. package/cjs/common/text.js.map +1 -1
  4. package/cjs/core/contributions/env/base-contribution.d.ts +1 -0
  5. package/cjs/core/contributions/env/base-contribution.js +3 -0
  6. package/cjs/core/contributions/env/base-contribution.js.map +1 -1
  7. package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +1 -1
  8. package/cjs/core/contributions/textMeasure/AtextMeasure.js +8 -4
  9. package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  10. package/cjs/core/global.d.ts +1 -0
  11. package/cjs/core/global.js +3 -0
  12. package/cjs/core/global.js.map +1 -1
  13. package/cjs/core/stage.d.ts +4 -0
  14. package/cjs/core/stage.js +6 -1
  15. package/cjs/core/stage.js.map +1 -1
  16. package/cjs/event/event-manager.js +9 -3
  17. package/cjs/event/event-manager.js.map +1 -1
  18. package/cjs/event/event-target.js +0 -2
  19. package/cjs/event/event-target.js.map +1 -1
  20. package/cjs/graphic/config.js +4 -0
  21. package/cjs/graphic/config.js.map +1 -1
  22. package/cjs/graphic/graphic-service/graphic-service.d.ts +1 -0
  23. package/cjs/graphic/graphic-service/graphic-service.js +23 -5
  24. package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
  25. package/cjs/graphic/graphic.d.ts +1 -0
  26. package/cjs/graphic/graphic.js +9 -6
  27. package/cjs/graphic/graphic.js.map +1 -1
  28. package/cjs/graphic/rect3d.js +1 -1
  29. package/cjs/graphic/rect3d.js.map +1 -1
  30. package/cjs/graphic/richtext/frame.js +9 -9
  31. package/cjs/graphic/richtext/frame.js.map +1 -1
  32. package/cjs/graphic/richtext/line.d.ts +2 -2
  33. package/cjs/graphic/richtext/line.js +9 -6
  34. package/cjs/graphic/richtext/line.js.map +1 -1
  35. package/cjs/graphic/richtext/paragraph.d.ts +2 -0
  36. package/cjs/graphic/richtext/paragraph.js +5 -5
  37. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  38. package/cjs/graphic/richtext/utils.js +4 -2
  39. package/cjs/graphic/richtext/utils.js.map +1 -1
  40. package/cjs/graphic/richtext.d.ts +6 -0
  41. package/cjs/graphic/richtext.js +16 -4
  42. package/cjs/graphic/richtext.js.map +1 -1
  43. package/cjs/graphic/text.js +1 -1
  44. package/cjs/graphic/text.js.map +1 -1
  45. package/cjs/graphic/theme.js +0 -2
  46. package/cjs/graphic/theme.js.map +1 -1
  47. package/cjs/interface/animate.d.ts +1 -0
  48. package/cjs/interface/animate.js.map +1 -1
  49. package/cjs/interface/contribution.d.ts +1 -0
  50. package/cjs/interface/contribution.js.map +1 -1
  51. package/cjs/interface/event.d.ts +0 -3
  52. package/cjs/interface/event.js.map +1 -1
  53. package/cjs/interface/global.d.ts +2 -0
  54. package/cjs/interface/global.js.map +1 -1
  55. package/cjs/interface/graphic/richText.d.ts +6 -2
  56. package/cjs/interface/graphic/richText.js.map +1 -1
  57. package/cjs/interface/graphic/theme.d.ts +0 -3
  58. package/cjs/interface/graphic/theme.js.map +1 -1
  59. package/cjs/interface/graphic.d.ts +25 -19
  60. package/cjs/interface/graphic.js.map +1 -1
  61. package/cjs/interface/stage.d.ts +8 -0
  62. package/cjs/interface/stage.js.map +1 -1
  63. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +5 -3
  64. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
  65. package/cjs/plugins/builtin-plugin/html-attribute-plugin.d.ts +21 -4
  66. package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +116 -54
  67. package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
  68. package/cjs/plugins/builtin-plugin/react-attribute-plugin.d.ts +8 -1
  69. package/cjs/plugins/builtin-plugin/react-attribute-plugin.js +32 -43
  70. package/cjs/plugins/builtin-plugin/react-attribute-plugin.js.map +1 -1
  71. package/cjs/render/contributions/render/base-render.js +8 -0
  72. package/cjs/render/contributions/render/base-render.js.map +1 -1
  73. package/cjs/render/contributions/render/contributions/rect-contribution-render.js +4 -2
  74. package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
  75. package/cjs/render/contributions/render/contributions/text-contribution-render.js +9 -3
  76. package/cjs/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  77. package/cjs/render/contributions/render/draw-contribution.js +2 -2
  78. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  79. package/cjs/render/contributions/render/draw-interceptor.js +7 -0
  80. package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
  81. package/cjs/render/contributions/render/rect3d-render.js +1 -1
  82. package/cjs/render/contributions/render/rect3d-render.js.map +1 -1
  83. package/cjs/render/contributions/render/text-render.js +2 -2
  84. package/cjs/render/contributions/render/text-render.js.map +1 -1
  85. package/cjs/render/contributions/render/utils.js +1 -1
  86. package/cjs/render/contributions/render/utils.js.map +1 -1
  87. package/cjs/render/render-modules.js +1 -1
  88. package/cjs/render/render-modules.js.map +1 -1
  89. package/cjs/render/render-service.js +1 -1
  90. package/cjs/render/render-service.js.map +1 -1
  91. package/es/common/text.d.ts +3 -2
  92. package/es/common/text.js +13 -0
  93. package/es/common/text.js.map +1 -1
  94. package/es/core/contributions/env/base-contribution.d.ts +1 -0
  95. package/es/core/contributions/env/base-contribution.js +3 -0
  96. package/es/core/contributions/env/base-contribution.js.map +1 -1
  97. package/es/core/contributions/textMeasure/AtextMeasure.d.ts +1 -1
  98. package/es/core/contributions/textMeasure/AtextMeasure.js +8 -4
  99. package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  100. package/es/core/global.d.ts +1 -0
  101. package/es/core/global.js +3 -0
  102. package/es/core/global.js.map +1 -1
  103. package/es/core/stage.d.ts +4 -0
  104. package/es/core/stage.js +6 -1
  105. package/es/core/stage.js.map +1 -1
  106. package/es/event/event-manager.js +9 -3
  107. package/es/event/event-manager.js.map +1 -1
  108. package/es/event/event-target.js +0 -2
  109. package/es/event/event-target.js.map +1 -1
  110. package/es/graphic/config.js +4 -0
  111. package/es/graphic/config.js.map +1 -1
  112. package/es/graphic/graphic-service/graphic-service.d.ts +1 -0
  113. package/es/graphic/graphic-service/graphic-service.js +23 -8
  114. package/es/graphic/graphic-service/graphic-service.js.map +1 -1
  115. package/es/graphic/graphic.d.ts +1 -0
  116. package/es/graphic/graphic.js +9 -6
  117. package/es/graphic/graphic.js.map +1 -1
  118. package/es/graphic/rect3d.js +1 -1
  119. package/es/graphic/rect3d.js.map +1 -1
  120. package/es/graphic/richtext/frame.js +9 -9
  121. package/es/graphic/richtext/frame.js.map +1 -1
  122. package/es/graphic/richtext/line.d.ts +2 -2
  123. package/es/graphic/richtext/line.js +9 -6
  124. package/es/graphic/richtext/line.js.map +1 -1
  125. package/es/graphic/richtext/paragraph.d.ts +2 -0
  126. package/es/graphic/richtext/paragraph.js +5 -5
  127. package/es/graphic/richtext/paragraph.js.map +1 -1
  128. package/es/graphic/richtext/utils.js +4 -2
  129. package/es/graphic/richtext/utils.js.map +1 -1
  130. package/es/graphic/richtext.d.ts +6 -0
  131. package/es/graphic/richtext.js +16 -4
  132. package/es/graphic/richtext.js.map +1 -1
  133. package/es/graphic/text.js +1 -1
  134. package/es/graphic/text.js.map +1 -1
  135. package/es/graphic/theme.js +1 -3
  136. package/es/graphic/theme.js.map +1 -1
  137. package/es/interface/animate.d.ts +1 -0
  138. package/es/interface/animate.js.map +1 -1
  139. package/es/interface/contribution.d.ts +1 -0
  140. package/es/interface/contribution.js.map +1 -1
  141. package/es/interface/event.d.ts +0 -3
  142. package/es/interface/event.js.map +1 -1
  143. package/es/interface/global.d.ts +2 -0
  144. package/es/interface/global.js.map +1 -1
  145. package/es/interface/graphic/richText.d.ts +6 -2
  146. package/es/interface/graphic/richText.js.map +1 -1
  147. package/es/interface/graphic/theme.d.ts +0 -3
  148. package/es/interface/graphic/theme.js.map +1 -1
  149. package/es/interface/graphic.d.ts +25 -19
  150. package/es/interface/graphic.js.map +1 -1
  151. package/es/interface/stage.d.ts +8 -0
  152. package/es/interface/stage.js.map +1 -1
  153. package/es/plugins/builtin-plugin/flex-layout-plugin.js +5 -3
  154. package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
  155. package/es/plugins/builtin-plugin/html-attribute-plugin.d.ts +21 -4
  156. package/es/plugins/builtin-plugin/html-attribute-plugin.js +117 -54
  157. package/es/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
  158. package/es/plugins/builtin-plugin/react-attribute-plugin.d.ts +8 -1
  159. package/es/plugins/builtin-plugin/react-attribute-plugin.js +32 -42
  160. package/es/plugins/builtin-plugin/react-attribute-plugin.js.map +1 -1
  161. package/es/render/contributions/render/base-render.js +8 -0
  162. package/es/render/contributions/render/base-render.js.map +1 -1
  163. package/es/render/contributions/render/contributions/rect-contribution-render.js +4 -2
  164. package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
  165. package/es/render/contributions/render/contributions/text-contribution-render.js +9 -3
  166. package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  167. package/es/render/contributions/render/draw-contribution.js +2 -2
  168. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  169. package/es/render/contributions/render/draw-interceptor.js +7 -0
  170. package/es/render/contributions/render/draw-interceptor.js.map +1 -1
  171. package/es/render/contributions/render/rect3d-render.js +1 -1
  172. package/es/render/contributions/render/rect3d-render.js.map +1 -1
  173. package/es/render/contributions/render/text-render.js +2 -2
  174. package/es/render/contributions/render/text-render.js.map +1 -1
  175. package/es/render/contributions/render/utils.js +1 -1
  176. package/es/render/contributions/render/utils.js.map +1 -1
  177. package/es/render/render-modules.js +1 -1
  178. package/es/render/render-modules.js.map +1 -1
  179. package/es/render/render-service.js +1 -1
  180. package/es/render/render-service.js.map +1 -1
  181. package/package.json +4 -4
@@ -119,11 +119,8 @@ export interface IFederatedPointerEvent extends IFederatedMouseEvent {
119
119
  clone: () => IFederatedPointerEvent;
120
120
  }
121
121
  export interface IEventTarget extends INode {
122
- pickable: boolean;
123
122
  parent: IEventTarget | null;
124
- visible: boolean;
125
123
  children?: IEventTarget[];
126
- childrenPickable?: boolean;
127
124
  attribute?: Partial<IGraphicAttribute>;
128
125
  emit: (eventName: any, data: Dict<any>) => boolean;
129
126
  getCursor: () => string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/event.ts"],"names":[],"mappings":"","file":"event.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { Dict, IBounds } from '@visactor/vutils';\nimport type { Cursor, IGraphicAttribute } from './graphic';\nimport type { IDomRectLike, IEventElement } from './common';\nimport type { ICanvas } from './canvas';\nimport type { IGlobal } from './global';\nimport type { IWindow } from './window';\n\nexport type EventPoint = {\n x: number;\n y: number;\n};\n\nexport interface IEventManager {\n rootTarget: IEventTarget;\n dispatch: any;\n cursor: Cursor | string;\n addEventMapping: (type: string, fn: (e: IFederatedEvent, target: IEventTarget) => void) => void;\n dispatchEvent: (e: IFederatedEvent, type?: string) => void;\n mapEvent: (e: IFederatedEvent) => void;\n propagate: (e: IFederatedEvent, type?: string) => void;\n propagationPath: (target: IEventTarget) => IEventTarget[];\n copyWheelData: (from: IFederatedWheelEvent, to: IFederatedWheelEvent) => void;\n copyPointerData: (from: IFederatedEvent, to: IFederatedEvent) => void;\n copyMouseData: (from: IFederatedEvent, to: IFederatedEvent) => void;\n copyData: (from: IFederatedEvent, to: IFederatedEvent) => void;\n}\n\nexport interface IFederatedEvent<N = Event> {\n bubbles: boolean;\n cancelBubble: boolean;\n cancelable: boolean;\n composed: boolean;\n currentTarget: IEventTarget | null;\n defaultPrevented: boolean;\n eventPhase: number;\n isTrusted: boolean;\n returnValue: boolean;\n srcElement: IEventTarget;\n target: IEventTarget | null;\n timeStamp: number;\n type: string;\n nativeEvent: N;\n originalEvent: IFederatedEvent<N> | null;\n propagationStopped: boolean;\n propagationImmediatelyStopped: boolean;\n path: IEventTarget[];\n manager?: IEventManager;\n detail: any;\n view: any;\n layer: EventPoint;\n get layerX(): number;\n get layerY(): number;\n page: EventPoint;\n get pageX(): number;\n get pageY(): number;\n canvas: EventPoint;\n get x(): number;\n get y(): number;\n get canvasX(): number;\n get canvasY(): number;\n viewport: EventPoint;\n get viewX(): number;\n get viewY(): number;\n composedPath: () => IEventTarget[];\n preventDefault: () => void;\n stopImmediatePropagation: () => void;\n stopPropagation: () => void;\n initEvent: () => void;\n initUIEvent: () => void;\n clone: () => void;\n which: number;\n}\n\nexport interface IFederatedMouseEvent extends IFederatedEvent {\n altKey: boolean;\n button: number;\n buttons: number;\n ctrlKey: boolean;\n metaKey: boolean;\n relatedTarget: EventTarget | null;\n shiftKey: boolean;\n client: EventPoint;\n get clientX(): number;\n get clientY(): number;\n detail: number;\n movement: EventPoint;\n get movementX(): number;\n get movementY(): number;\n offset: EventPoint;\n get offsetX(): number;\n get offsetY(): number;\n global: EventPoint;\n get globalX(): number;\n get globalY(): number;\n screen: EventPoint;\n get screenX(): number;\n get screenY(): number;\n getModifierState: (key: string) => boolean;\n initMouseEvent: (\n _typeArg: string,\n _canBubbleArg: boolean,\n _cancelableArg: boolean,\n _viewArg: Window,\n _detailArg: number,\n _screenXArg: number,\n _screenYArg: number,\n _clientXArg: number,\n _clientYArg: number,\n _ctrlKeyArg: boolean,\n _altKeyArg: boolean,\n _shiftKeyArg: boolean,\n _metaKeyArg: boolean,\n _buttonArg: number,\n _relatedTargetArg: EventTarget\n ) => void;\n}\n\nexport interface IFederatedWheelEvent extends IFederatedMouseEvent {\n deltaMode: number;\n deltaX: number;\n deltaY: number;\n deltaZ: number;\n clone: () => IFederatedWheelEvent;\n}\n\nexport interface IFederatedPointerEvent extends IFederatedMouseEvent {\n pointerId: number;\n width: number;\n height: number;\n isPrimary: boolean;\n pointerType: string;\n pressure: number;\n tangentialPressure: number;\n tiltX: number;\n tiltY: number;\n twist: number;\n detail: number;\n getCoalescedEvents: () => PointerEvent[];\n getPredictedEvents: () => PointerEvent[];\n clone: () => IFederatedPointerEvent;\n}\n\n/**\n * 代码参考自 https://github.com/pixijs/pixijs\n * The MIT License\n\n Copyright (c) 2013-2023 Mathew Groves, Chad Engler\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.\n */\n\nexport interface IEventTarget extends INode {\n /** Whether this event target should fire UI events. */\n pickable: boolean;\n /** The parent of this event target. */\n parent: IEventTarget | null;\n /** Whether this event target should be visible. */\n visible: boolean;\n\n /** The children of this event target. */\n children?: IEventTarget[];\n\n /** Whether this event target has any children that need UI events. This can be used optimize event propagation. */\n childrenPickable?: boolean;\n\n attribute?: Partial<IGraphicAttribute>;\n\n emit: (eventName: any, data: Dict<any>) => boolean;\n\n getCursor: () => string;\n setCursor: (c?: string) => void;\n}\n\nexport interface IRender {\n visualCanvas: {\n getCanvas: () => HTMLElement;\n };\n pickEvent: (position: [number, number], children: IEventTarget[], geoPick?: boolean) => IEventTarget | null;\n [key: string]: any;\n}\n\n// 事件系统扩展接口\nexport interface IEventExtension {\n /**\n * bind events\n */\n initEvents: () => void;\n /**\n * unbind events\n */\n removeEvents: () => void;\n /**\n * release\n */\n release: () => void;\n}\n\nexport type LooseFunction = (...args: any[]) => any;\n\nexport type IElementLike = Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> & {\n style: CSSStyleDeclaration | Record<string, any>;\n getNativeHandler?: () => ICanvas;\n getBoundingClientRect: () => IDomRectLike;\n};\n\nexport type RenderConfig = {\n /**\n * 事件绑定的元素\n */\n targetElement: IWindow;\n /**\n * 环境分辨率\n */\n resolution: number;\n /**\n * 场景树根节点\n */\n rootNode: IEventTarget;\n global: IGlobal;\n /** 是否自动阻止事件 */\n autoPreventDefault?: boolean;\n /**\n * 多次点击之间的最大时间,默认为 200 ms\n * @default 200\n */\n clickInterval?: number;\n\n /**\n * @since 0.17.15\n * 是否支持touch事件,不支持就不监听touch事件\n */\n supportsTouchEvents?: boolean;\n\n /**\n * @since 0.17.15\n * 是否支持pointer事件,不支持就监听mouse事件\n */\n supportsPointerEvents?: boolean;\n};\n\nexport type NativeEvent = MouseEvent | PointerEvent | TouchEvent;\n\nexport type GraphicEventType =\n | 'pointerdown'\n | 'pointerup'\n // 指针抬起与按下的图形不同时触发\n | 'pointerupoutside'\n | 'pointertap'\n | 'pointerover'\n | 'pointerenter'\n | 'pointerleave'\n | 'pointerout'\n | 'mousedown'\n | 'mouseup'\n | 'mouseupoutside'\n // 右键操作\n | 'rightdown'\n | 'rightup'\n | 'rightupoutside'\n | 'click'\n // 双击\n | 'dblclick'\n | 'mousemove'\n | 'mouseover'\n | 'mouseout'\n // 不会冒泡\n | 'mouseenter'\n // 不会冒泡\n | 'mouseleave'\n | 'wheel'\n | 'tap'\n | 'touchstart'\n | 'touchend'\n | 'touchendoutside'\n | 'touchmove'\n | 'touchcancel'\n // dragNdrop\n | 'dragstart'\n | 'drag'\n | 'dragenter'\n | 'dragleave'\n | 'dragover'\n | 'dragend'\n | 'drop'\n // gesture\n | 'pan'\n | 'panstart'\n | 'panend'\n | 'press'\n | 'pressup'\n | 'pressend'\n | 'pinch'\n | 'pinchstart'\n | 'pinchend'\n | 'swipe';\n"]}
1
+ {"version":3,"sources":["../src/interface/event.ts"],"names":[],"mappings":"","file":"event.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { Dict, IBounds } from '@visactor/vutils';\nimport type { Cursor, IGraphicAttribute } from './graphic';\nimport type { IDomRectLike, IEventElement } from './common';\nimport type { ICanvas } from './canvas';\nimport type { IGlobal } from './global';\nimport type { IWindow } from './window';\n\nexport type EventPoint = {\n x: number;\n y: number;\n};\n\nexport interface IEventManager {\n rootTarget: IEventTarget;\n dispatch: any;\n cursor: Cursor | string;\n addEventMapping: (type: string, fn: (e: IFederatedEvent, target: IEventTarget) => void) => void;\n dispatchEvent: (e: IFederatedEvent, type?: string) => void;\n mapEvent: (e: IFederatedEvent) => void;\n propagate: (e: IFederatedEvent, type?: string) => void;\n propagationPath: (target: IEventTarget) => IEventTarget[];\n copyWheelData: (from: IFederatedWheelEvent, to: IFederatedWheelEvent) => void;\n copyPointerData: (from: IFederatedEvent, to: IFederatedEvent) => void;\n copyMouseData: (from: IFederatedEvent, to: IFederatedEvent) => void;\n copyData: (from: IFederatedEvent, to: IFederatedEvent) => void;\n}\n\nexport interface IFederatedEvent<N = Event> {\n bubbles: boolean;\n cancelBubble: boolean;\n cancelable: boolean;\n composed: boolean;\n currentTarget: IEventTarget | null;\n defaultPrevented: boolean;\n eventPhase: number;\n isTrusted: boolean;\n returnValue: boolean;\n srcElement: IEventTarget;\n target: IEventTarget | null;\n timeStamp: number;\n type: string;\n nativeEvent: N;\n originalEvent: IFederatedEvent<N> | null;\n propagationStopped: boolean;\n propagationImmediatelyStopped: boolean;\n path: IEventTarget[];\n manager?: IEventManager;\n detail: any;\n view: any;\n layer: EventPoint;\n get layerX(): number;\n get layerY(): number;\n page: EventPoint;\n get pageX(): number;\n get pageY(): number;\n canvas: EventPoint;\n get x(): number;\n get y(): number;\n get canvasX(): number;\n get canvasY(): number;\n viewport: EventPoint;\n get viewX(): number;\n get viewY(): number;\n composedPath: () => IEventTarget[];\n preventDefault: () => void;\n stopImmediatePropagation: () => void;\n stopPropagation: () => void;\n initEvent: () => void;\n initUIEvent: () => void;\n clone: () => void;\n which: number;\n}\n\nexport interface IFederatedMouseEvent extends IFederatedEvent {\n altKey: boolean;\n button: number;\n buttons: number;\n ctrlKey: boolean;\n metaKey: boolean;\n relatedTarget: EventTarget | null;\n shiftKey: boolean;\n client: EventPoint;\n get clientX(): number;\n get clientY(): number;\n detail: number;\n movement: EventPoint;\n get movementX(): number;\n get movementY(): number;\n offset: EventPoint;\n get offsetX(): number;\n get offsetY(): number;\n global: EventPoint;\n get globalX(): number;\n get globalY(): number;\n screen: EventPoint;\n get screenX(): number;\n get screenY(): number;\n getModifierState: (key: string) => boolean;\n initMouseEvent: (\n _typeArg: string,\n _canBubbleArg: boolean,\n _cancelableArg: boolean,\n _viewArg: Window,\n _detailArg: number,\n _screenXArg: number,\n _screenYArg: number,\n _clientXArg: number,\n _clientYArg: number,\n _ctrlKeyArg: boolean,\n _altKeyArg: boolean,\n _shiftKeyArg: boolean,\n _metaKeyArg: boolean,\n _buttonArg: number,\n _relatedTargetArg: EventTarget\n ) => void;\n}\n\nexport interface IFederatedWheelEvent extends IFederatedMouseEvent {\n deltaMode: number;\n deltaX: number;\n deltaY: number;\n deltaZ: number;\n clone: () => IFederatedWheelEvent;\n}\n\nexport interface IFederatedPointerEvent extends IFederatedMouseEvent {\n pointerId: number;\n width: number;\n height: number;\n isPrimary: boolean;\n pointerType: string;\n pressure: number;\n tangentialPressure: number;\n tiltX: number;\n tiltY: number;\n twist: number;\n detail: number;\n getCoalescedEvents: () => PointerEvent[];\n getPredictedEvents: () => PointerEvent[];\n clone: () => IFederatedPointerEvent;\n}\n\n/**\n * 代码参考自 https://github.com/pixijs/pixijs\n * The MIT License\n\n Copyright (c) 2013-2023 Mathew Groves, Chad Engler\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.\n */\n\nexport interface IEventTarget extends INode {\n /** The parent of this event target. */\n parent: IEventTarget | null;\n\n /** The children of this event target. */\n children?: IEventTarget[];\n\n attribute?: Partial<IGraphicAttribute>;\n\n emit: (eventName: any, data: Dict<any>) => boolean;\n\n getCursor: () => string;\n setCursor: (c?: string) => void;\n}\n\nexport interface IRender {\n visualCanvas: {\n getCanvas: () => HTMLElement;\n };\n pickEvent: (position: [number, number], children: IEventTarget[], geoPick?: boolean) => IEventTarget | null;\n [key: string]: any;\n}\n\n// 事件系统扩展接口\nexport interface IEventExtension {\n /**\n * bind events\n */\n initEvents: () => void;\n /**\n * unbind events\n */\n removeEvents: () => void;\n /**\n * release\n */\n release: () => void;\n}\n\nexport type LooseFunction = (...args: any[]) => any;\n\nexport type IElementLike = Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> & {\n style: CSSStyleDeclaration | Record<string, any>;\n getNativeHandler?: () => ICanvas;\n getBoundingClientRect: () => IDomRectLike;\n};\n\nexport type RenderConfig = {\n /**\n * 事件绑定的元素\n */\n targetElement: IWindow;\n /**\n * 环境分辨率\n */\n resolution: number;\n /**\n * 场景树根节点\n */\n rootNode: IEventTarget;\n global: IGlobal;\n /** 是否自动阻止事件 */\n autoPreventDefault?: boolean;\n /**\n * 多次点击之间的最大时间,默认为 200 ms\n * @default 200\n */\n clickInterval?: number;\n\n /**\n * @since 0.17.15\n * 是否支持touch事件,不支持就不监听touch事件\n */\n supportsTouchEvents?: boolean;\n\n /**\n * @since 0.17.15\n * 是否支持pointer事件,不支持就监听mouse事件\n */\n supportsPointerEvents?: boolean;\n};\n\nexport type NativeEvent = MouseEvent | PointerEvent | TouchEvent;\n\nexport type GraphicEventType =\n | 'pointerdown'\n | 'pointerup'\n // 指针抬起与按下的图形不同时触发\n | 'pointerupoutside'\n | 'pointertap'\n | 'pointerover'\n | 'pointerenter'\n | 'pointerleave'\n | 'pointerout'\n | 'mousedown'\n | 'mouseup'\n | 'mouseupoutside'\n // 右键操作\n | 'rightdown'\n | 'rightup'\n | 'rightupoutside'\n | 'click'\n // 双击\n | 'dblclick'\n | 'mousemove'\n | 'mouseover'\n | 'mouseout'\n // 不会冒泡\n | 'mouseenter'\n // 不会冒泡\n | 'mouseleave'\n | 'wheel'\n | 'tap'\n | 'touchstart'\n | 'touchend'\n | 'touchendoutside'\n | 'touchmove'\n | 'touchcancel'\n // dragNdrop\n | 'dragstart'\n | 'drag'\n | 'dragenter'\n | 'dragleave'\n | 'dragover'\n | 'dragend'\n | 'drop'\n // gesture\n | 'pan'\n | 'panstart'\n | 'panend'\n | 'press'\n | 'pressup'\n | 'pressend'\n | 'pinch'\n | 'pinchstart'\n | 'pinchend'\n | 'swipe';\n"]}
@@ -28,6 +28,7 @@ export interface IEnvContribution extends IContribution<IGlobal>, Omit<IEventEle
28
28
  getNativeAABBBounds: (dom: string | HTMLElement | any) => IAABBBoundsLike;
29
29
  removeDom: (dom: HTMLElement) => boolean;
30
30
  createDom: (params: CreateDOMParamsType) => HTMLElement | null;
31
+ updateDom: (dom: HTMLElement, params: CreateDOMParamsType) => boolean;
31
32
  getElementTop: (dom: any, baseWindow?: boolean) => number;
32
33
  getElementLeft: (dom: any, baseWindow?: boolean) => number;
33
34
  getElementTopLeft: (dom: any, baseWindow?: boolean) => {
@@ -145,6 +146,7 @@ export interface IGlobal extends Omit<IEventElement, 'on' | 'off' | 'once' | 'em
145
146
  }>;
146
147
  removeDom: (dom: HTMLElement) => boolean;
147
148
  createDom: (params: CreateDOMParamsType) => HTMLElement | null;
149
+ updateDom: (dom: HTMLElement, params: CreateDOMParamsType) => boolean;
148
150
  getElementTop: (dom: any, baseWindow?: boolean) => number;
149
151
  getElementLeft: (dom: any, baseWindow?: boolean) => number;
150
152
  getElementTopLeft: (dom: any, baseWindow?: boolean) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/global.ts"],"names":[],"mappings":"","file":"global.js","sourcesContent":["import type { Dict, IAABBBoundsLike, IPointLike } from '@visactor/vutils';\nimport type { ICanvasLike } from './canvas';\nimport type { IEventElement } from './common';\nimport type { IContribution } from './contribution';\nimport type { ISyncHook } from './sync-hook';\n\nexport interface ILoader {\n loadImage: (url: string) => HTMLImageElement | ImageData;\n loadJson: (url: string) => JSON;\n}\n\n// 环境定义\nexport type EnvType = 'browser' | 'feishu' | 'tt' | 'taro' | 'node' | 'native' | 'lynx' | 'wx';\n\n// 创建canvas需要的参数\nexport interface ICreateCanvasParams {\n id?: string;\n // 像素宽\n width?: number;\n // 像素高\n height?: number;\n dpr?: number;\n}\n\nexport interface ILoader {\n loadImage: (url: string) => HTMLImageElement | ImageData;\n loadJson: (url: string) => JSON;\n}\n\nexport interface IEnvContribution\n extends IContribution<IGlobal>,\n Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> {\n // 当前代码所运行的环境\n type: EnvType;\n\n // 是否支持事件\n // node环境不需要事件\n supportEvent: boolean;\n\n // 开始配置环境,相当于init\n configure: (global: IGlobal, ...p: any) => void;\n\n // 创建销毁\n createCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;\n createOffscreenCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;\n releaseCanvas: (canvas: ICanvasLike | string | any) => void;\n\n getNativeAABBBounds: (dom: string | HTMLElement | any) => IAABBBoundsLike;\n removeDom: (dom: HTMLElement) => boolean;\n createDom: (params: CreateDOMParamsType) => HTMLElement | null;\n getElementTop: (dom: any, baseWindow?: boolean) => number;\n getElementLeft: (dom: any, baseWindow?: boolean) => number;\n getElementTopLeft: (dom: any, baseWindow?: boolean) => { top: number; left: number };\n\n /**\n * 获取动态canvas的数量,offscreenCanvas或者framebuffer\n */\n getDynamicCanvasCount: () => number;\n\n /**\n * 获取静态canvas的数量,纯粹canvas\n */\n getStaticCanvasCount: () => number;\n\n // 设备信息\n getDevicePixelRatio: () => number;\n\n // 通用接口\n getRequestAnimationFrame: () => (callback: FrameRequestCallback) => number;\n getCancelAnimationFrame: () => (h: number) => void;\n\n // DOM接口\n getElementById?: (str: string) => HTMLElement | null;\n getRootElement?: () => HTMLElement | null;\n /**\n * get document instance\n */\n getDocument?: () => Document | null;\n /**\n * whether supports TouchEvent.\n */\n supportsTouchEvents: boolean;\n /**\n * whether supports PointerEvent.\n */\n supportsPointerEvents: boolean;\n /**\n * whether supports MouseEvent.\n */\n supportsMouseEvents: boolean;\n /**\n * Whether to allow setting the cursor style\n */\n applyStyles?: boolean;\n\n /**\n * 将窗口坐标转换为画布坐标,小程序/小组件环境需要兼容\n */\n mapToCanvasPoint?: (event: any, domElement?: any) => IPointLike | null;\n\n loadImage: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadSvg: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadJson: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Record<string, unknown> | null;\n }>;\n loadArrayBuffer: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: ArrayBuffer | null;\n }>;\n loadBlob: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Blob | null;\n }>;\n}\n\nexport type IMiniAppEnvParams = {\n /** dom 容器对象 */\n domref?: Dict<any>;\n /**\n * 强行设置env,如果env重复设置也设置\n */\n force?: boolean;\n /**\n * 可用的canvas列表\n */\n canvasIdLists?: (string | number)[];\n /**\n * 表示可以自由使用的canvas索引\n */\n freeCanvasIdx?: string | number;\n /** taro 环境使用 */\n taro?: any;\n pixelRatio?: number;\n [key: string]: any;\n};\n\nexport interface IEnvParamsMap {\n readonly taro: IMiniAppEnvParams;\n readonly feishu: IMiniAppEnvParams;\n readonly tt: IMiniAppEnvParams;\n readonly browser: any;\n readonly node: any;\n readonly native: any;\n readonly lynx: any;\n readonly wx: any;\n}\n\nexport type CreateDOMParamsType = {\n tagName?: string;\n width?: number;\n height?: number;\n style?: string | Record<string, any>;\n parent?: string | HTMLElement;\n};\nexport interface IGlobal extends Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> {\n // 当前代码所运行的环境\n env: EnvType;\n\n // 设备的dpr\n devicePixelRatio: number;\n\n // 当设置env的时候被调用\n hooks: {\n onSetEnv: ISyncHook<[EnvType | undefined, EnvType, IGlobal]>;\n };\n\n // 设置env的时候传入的参数\n // node环境需要传入整个node-canvas包\n // 小程序环境需要传入小程序要用到的参数\n envParams?: any;\n\n // 是否支持事件\n // node环境不需要事件\n supportEvent: boolean;\n\n // 是否在不显示canvas的时候停止绘图操作,默认false\n optimizeVisible: boolean;\n\n setEnv: (env: EnvType, params?: IEnvParamsMap[EnvType]) => void;\n setActiveEnvContribution: (contribution: IEnvContribution) => void;\n createCanvas: (params: ICreateCanvasParams) => HTMLCanvasElement | any;\n createOffscreenCanvas: (params: ICreateCanvasParams) => HTMLCanvasElement | any;\n releaseCanvas: (canvas: HTMLCanvasElement | string | any) => void;\n\n /**\n * 获取环境中最大动态canvas的数量,offscreenCanvas或者framebuffer\n */\n getDynamicCanvasCount: () => number;\n\n isChrome: () => boolean;\n isSafari: () => boolean;\n\n /**\n * 获取环境中最大静态canvas的数量,纯粹canvas\n */\n getStaticCanvasCount: () => number;\n\n /* 浏览器环境 - dom tree */\n getElementById: (str: string) => HTMLElement | null;\n getRootElement: () => HTMLElement | null;\n /**\n * get document instance\n */\n getDocument: () => Document | null;\n /**\n * whether supports TouchEvent.\n */\n supportsTouchEvents: boolean;\n /**\n * whether supports PointerEvent.\n */\n supportsPointerEvents: boolean;\n /**\n * whether supports MouseEvent.\n */\n supportsMouseEvents: boolean;\n /**\n * Whether to allow setting the cursor style\n */\n applyStyles?: boolean;\n /**\n * 测量文字的方法\n */\n measureTextMethod: 'native' | 'simple' | 'quick';\n\n getRequestAnimationFrame: () => null | ((callback: FrameRequestCallback) => number);\n getCancelAnimationFrame: () => null | ((h: number) => void);\n\n /**\n * 将窗口坐标转换为画布坐标,小程序/小组件环境需要兼容\n */\n mapToCanvasPoint: (nativeEvent: any, domElement?: any) => IPointLike | null;\n\n loadImage: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadSvg: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadJson: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Record<string, unknown> | null;\n }>;\n loadArrayBuffer: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: ArrayBuffer | null;\n }>;\n loadBlob: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Blob | null;\n }>;\n\n removeDom: (dom: HTMLElement) => boolean;\n createDom: (params: CreateDOMParamsType) => HTMLElement | null;\n\n getElementTop: (dom: any, baseWindow?: boolean) => number;\n getElementLeft: (dom: any, baseWindow?: boolean) => number;\n getElementTopLeft: (dom: any, baseWindow?: boolean) => { top: number; left: number };\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/global.ts"],"names":[],"mappings":"","file":"global.js","sourcesContent":["import type { Dict, IAABBBoundsLike, IPointLike } from '@visactor/vutils';\nimport type { ICanvasLike } from './canvas';\nimport type { IEventElement } from './common';\nimport type { IContribution } from './contribution';\nimport type { ISyncHook } from './sync-hook';\n\nexport interface ILoader {\n loadImage: (url: string) => HTMLImageElement | ImageData;\n loadJson: (url: string) => JSON;\n}\n\n// 环境定义\nexport type EnvType = 'browser' | 'feishu' | 'tt' | 'taro' | 'node' | 'native' | 'lynx' | 'wx';\n\n// 创建canvas需要的参数\nexport interface ICreateCanvasParams {\n id?: string;\n // 像素宽\n width?: number;\n // 像素高\n height?: number;\n dpr?: number;\n}\n\nexport interface ILoader {\n loadImage: (url: string) => HTMLImageElement | ImageData;\n loadJson: (url: string) => JSON;\n}\n\nexport interface IEnvContribution\n extends IContribution<IGlobal>,\n Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> {\n // 当前代码所运行的环境\n type: EnvType;\n\n // 是否支持事件\n // node环境不需要事件\n supportEvent: boolean;\n\n // 开始配置环境,相当于init\n configure: (global: IGlobal, ...p: any) => void;\n\n // 创建销毁\n createCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;\n createOffscreenCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;\n releaseCanvas: (canvas: ICanvasLike | string | any) => void;\n\n getNativeAABBBounds: (dom: string | HTMLElement | any) => IAABBBoundsLike;\n removeDom: (dom: HTMLElement) => boolean;\n createDom: (params: CreateDOMParamsType) => HTMLElement | null;\n updateDom: (dom: HTMLElement, params: CreateDOMParamsType) => boolean;\n getElementTop: (dom: any, baseWindow?: boolean) => number;\n getElementLeft: (dom: any, baseWindow?: boolean) => number;\n getElementTopLeft: (dom: any, baseWindow?: boolean) => { top: number; left: number };\n\n /**\n * 获取动态canvas的数量,offscreenCanvas或者framebuffer\n */\n getDynamicCanvasCount: () => number;\n\n /**\n * 获取静态canvas的数量,纯粹canvas\n */\n getStaticCanvasCount: () => number;\n\n // 设备信息\n getDevicePixelRatio: () => number;\n\n // 通用接口\n getRequestAnimationFrame: () => (callback: FrameRequestCallback) => number;\n getCancelAnimationFrame: () => (h: number) => void;\n\n // DOM接口\n getElementById?: (str: string) => HTMLElement | null;\n getRootElement?: () => HTMLElement | null;\n /**\n * get document instance\n */\n getDocument?: () => Document | null;\n /**\n * whether supports TouchEvent.\n */\n supportsTouchEvents: boolean;\n /**\n * whether supports PointerEvent.\n */\n supportsPointerEvents: boolean;\n /**\n * whether supports MouseEvent.\n */\n supportsMouseEvents: boolean;\n /**\n * Whether to allow setting the cursor style\n */\n applyStyles?: boolean;\n\n /**\n * 将窗口坐标转换为画布坐标,小程序/小组件环境需要兼容\n */\n mapToCanvasPoint?: (event: any, domElement?: any) => IPointLike | null;\n\n loadImage: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadSvg: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadJson: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Record<string, unknown> | null;\n }>;\n loadArrayBuffer: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: ArrayBuffer | null;\n }>;\n loadBlob: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Blob | null;\n }>;\n}\n\nexport type IMiniAppEnvParams = {\n /** dom 容器对象 */\n domref?: Dict<any>;\n /**\n * 强行设置env,如果env重复设置也设置\n */\n force?: boolean;\n /**\n * 可用的canvas列表\n */\n canvasIdLists?: (string | number)[];\n /**\n * 表示可以自由使用的canvas索引\n */\n freeCanvasIdx?: string | number;\n /** taro 环境使用 */\n taro?: any;\n pixelRatio?: number;\n [key: string]: any;\n};\n\nexport interface IEnvParamsMap {\n readonly taro: IMiniAppEnvParams;\n readonly feishu: IMiniAppEnvParams;\n readonly tt: IMiniAppEnvParams;\n readonly browser: any;\n readonly node: any;\n readonly native: any;\n readonly lynx: any;\n readonly wx: any;\n}\n\nexport type CreateDOMParamsType = {\n tagName?: string;\n width?: number;\n height?: number;\n style?: string | Record<string, any>;\n parent?: string | HTMLElement;\n};\nexport interface IGlobal extends Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> {\n // 当前代码所运行的环境\n env: EnvType;\n\n // 设备的dpr\n devicePixelRatio: number;\n\n // 当设置env的时候被调用\n hooks: {\n onSetEnv: ISyncHook<[EnvType | undefined, EnvType, IGlobal]>;\n };\n\n // 设置env的时候传入的参数\n // node环境需要传入整个node-canvas包\n // 小程序环境需要传入小程序要用到的参数\n envParams?: any;\n\n // 是否支持事件\n // node环境不需要事件\n supportEvent: boolean;\n\n // 是否在不显示canvas的时候停止绘图操作,默认false\n optimizeVisible: boolean;\n\n setEnv: (env: EnvType, params?: IEnvParamsMap[EnvType]) => void;\n setActiveEnvContribution: (contribution: IEnvContribution) => void;\n createCanvas: (params: ICreateCanvasParams) => HTMLCanvasElement | any;\n createOffscreenCanvas: (params: ICreateCanvasParams) => HTMLCanvasElement | any;\n releaseCanvas: (canvas: HTMLCanvasElement | string | any) => void;\n\n /**\n * 获取环境中最大动态canvas的数量,offscreenCanvas或者framebuffer\n */\n getDynamicCanvasCount: () => number;\n\n isChrome: () => boolean;\n isSafari: () => boolean;\n\n /**\n * 获取环境中最大静态canvas的数量,纯粹canvas\n */\n getStaticCanvasCount: () => number;\n\n /* 浏览器环境 - dom tree */\n getElementById: (str: string) => HTMLElement | null;\n getRootElement: () => HTMLElement | null;\n /**\n * get document instance\n */\n getDocument: () => Document | null;\n /**\n * whether supports TouchEvent.\n */\n supportsTouchEvents: boolean;\n /**\n * whether supports PointerEvent.\n */\n supportsPointerEvents: boolean;\n /**\n * whether supports MouseEvent.\n */\n supportsMouseEvents: boolean;\n /**\n * Whether to allow setting the cursor style\n */\n applyStyles?: boolean;\n /**\n * 测量文字的方法\n */\n measureTextMethod: 'native' | 'simple' | 'quick';\n\n getRequestAnimationFrame: () => null | ((callback: FrameRequestCallback) => number);\n getCancelAnimationFrame: () => null | ((h: number) => void);\n\n /**\n * 将窗口坐标转换为画布坐标,小程序/小组件环境需要兼容\n */\n mapToCanvasPoint: (nativeEvent: any, domElement?: any) => IPointLike | null;\n\n loadImage: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadSvg: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadJson: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Record<string, unknown> | null;\n }>;\n loadArrayBuffer: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: ArrayBuffer | null;\n }>;\n loadBlob: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Blob | null;\n }>;\n\n removeDom: (dom: HTMLElement) => boolean;\n createDom: (params: CreateDOMParamsType) => HTMLElement | null;\n updateDom: (dom: HTMLElement, params: CreateDOMParamsType) => boolean;\n\n getElementTop: (dom: any, baseWindow?: boolean) => number;\n getElementLeft: (dom: any, baseWindow?: boolean) => number;\n getElementTopLeft: (dom: any, baseWindow?: boolean) => { top: number; left: number };\n}\n"]}
@@ -15,6 +15,7 @@ export type IRichTextAttribute = {
15
15
  textBaseline: RichTextGlobalBaselineType;
16
16
  layoutDirection: RichTextLayoutDirectionType;
17
17
  textConfig: IRichTextCharacter[];
18
+ disableAutoWrapLine: boolean;
18
19
  singleLine: boolean;
19
20
  };
20
21
  export type IRichTextGraphicAttribute = Partial<IGraphicAttribute & ITextGraphicAttribute> & Partial<IRichTextAttribute>;
@@ -45,6 +46,9 @@ export type IRichTextParagraphCharacter = IRichTextBasicCharacter & {
45
46
  script?: RichTextScript;
46
47
  underline?: boolean;
47
48
  lineThrough?: boolean;
49
+ opacity?: number;
50
+ fillOpacity?: number;
51
+ strokeOpacity?: number;
48
52
  };
49
53
  export type IRichTextImageCharacter = IRichTextBasicCharacter & {
50
54
  image: string | HTMLImageElement | HTMLCanvasElement;
@@ -124,8 +128,8 @@ export interface IRichTextLine {
124
128
  x: string;
125
129
  y: string;
126
130
  };
127
- draw: (ctx: IContext2d, lastLine: boolean, x: number, y: number, drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void) => void;
128
- getWidthWithEllips: () => number;
131
+ draw: (ctx: IContext2d, lastLine: boolean, x: number, y: number, drawEllipsis: boolean | string, drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void) => void;
132
+ getWidthWithEllips: (ellipsis: string) => number;
129
133
  }
130
134
  export interface IRichTextFrame {
131
135
  left: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/richText.ts"],"names":[],"mappings":"","file":"richText.js","sourcesContent":["import type { IColor } from '../color';\nimport type { IContext2d } from '../context';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { IImage, IImageGraphicAttribute } from './image';\nimport type { ITextGraphicAttribute } from './text';\n\nexport type IRichTextAttribute = {\n width: number;\n height: number;\n ellipsis: boolean | string;\n wordBreak: RichTextWordBreak;\n verticalDirection: RichTextVerticalDirection;\n maxHeight: number;\n maxWidth: number;\n textAlign: RichTextGlobalAlignType;\n textBaseline: RichTextGlobalBaselineType;\n layoutDirection: RichTextLayoutDirectionType;\n textConfig: IRichTextCharacter[];\n singleLine: boolean;\n};\n\nexport type IRichTextGraphicAttribute = Partial<IGraphicAttribute & ITextGraphicAttribute> &\n Partial<IRichTextAttribute>;\n\nexport type RichTextWordBreak = 'break-word' | 'break-all';\nexport type RichTextVerticalDirection = 'top' | 'middle' | 'bottom';\nexport type RichTextGlobalAlignType = 'left' | 'right' | 'center';\nexport type RichTextGlobalBaselineType = 'top' | 'middle' | 'bottom';\nexport type RichTextLayoutDirectionType = 'horizontal' | 'vertical';\nexport type RichTextFontStyle = 'normal' | 'italic' | 'oblique';\nexport type RichTextTextDecoration = 'none' | 'underline' | 'line-through';\n// export type RichTextTextAlign = 'left' | 'right' | 'center';\nexport type RichTextScript = 'normal' | 'sub' | 'super';\n\nexport type IRichTextBasicCharacter = {\n lineHeight?: number | string;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextParagraphCharacter = IRichTextBasicCharacter & {\n text: string | number;\n fontSize?: number;\n fontFamily?: string;\n fill?: IColor | boolean;\n stroke?: IColor | boolean;\n fontWeight?: string;\n lineWidth?: number;\n // lineHeight?: number;\n fontStyle?: RichTextFontStyle; // normal, italic, oblique\n textDecoration?: RichTextTextDecoration; // none, underline, line-through\n // textAlign?: RichTextTextAlign; // left, right, center\n script?: RichTextScript; // normal, sub, super\n underline?: boolean;\n lineThrough?: boolean;\n // direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextImageCharacter = IRichTextBasicCharacter & {\n // 图片基础属性\n image: string | HTMLImageElement | HTMLCanvasElement;\n width: number;\n height: number;\n\n // hover相关属性\n // backgroundShow?: boolean; // 是否显示background\n backgroundShowMode?: 'always' | 'hover';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n // background size 同时控制了该icon的响应范围\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // 唯一标识符\n id?: string;\n\n // lineHeight?: number;\n // textAlign?: RichTextTextAlign; // left, right, center\n // direction?: RichTextLayoutDirectionType;\n margin?: number | number[];\n\n funcType?: string;\n hoverImage?: string | HTMLImageElement | HTMLCanvasElement;\n};\n\nexport type IRichTextCharacter = IRichTextParagraphCharacter | IRichTextImageCharacter;\n\nexport type IRichTextIconGraphicAttribute = IImageGraphicAttribute & {\n id?: string;\n backgroundShowMode?: 'always' | 'hover' | 'never';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // lineHeight?: number;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n\n margin?: number | number[];\n\n // backgroundShow?: boolean;\n};\n\nexport interface IRichTextParagraph {\n text: string;\n ascent: number;\n descent: number;\n width: number;\n height: number;\n lineHeight: number;\n fontSize: number;\n length: number;\n newLine: boolean;\n character: IRichTextParagraphCharacter;\n left: number;\n top: number;\n direction?: 'horizontal' | 'vertical';\n widthOrigin?: number;\n heightOrigin?: number;\n textBaseline?: CanvasTextBaseline;\n ellipsis: 'normal' | 'add' | 'replace' | 'hide';\n ellipsisWidth: number;\n ellipsisOtherParagraphWidth: number;\n verticalEllipsis?: boolean;\n updateWidth: () => void;\n draw: (ctx: IContext2d, baseline: number, deltaLeft: number, isLineFirst: boolean, textAlign: string) => void;\n getWidthWithEllips: (direction: string) => number;\n}\n\nexport interface IRichTextLine {\n left: number;\n top: number;\n width: number;\n height: number;\n baseline: number;\n ascent: number;\n descent: number;\n paragraphs: (IRichTextParagraph | IRichTextIcon)[];\n actualWidth: number;\n blankWidth: number;\n textAlign: string;\n direction: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n x: string;\n y: string;\n };\n draw: (\n ctx: IContext2d,\n lastLine: boolean,\n x: number,\n y: number,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => void;\n getWidthWithEllips: () => number;\n}\n\nexport interface IRichTextFrame {\n left: number;\n top: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n actualHeight: number;\n ellipsis: boolean | string;\n wordBreak: 'break-word' | 'break-all';\n verticalDirection: 'top' | 'middle' | 'bottom';\n lines: IRichTextLine[];\n globalAlign: 'left' | 'center' | 'right' | 'start' | 'end';\n globalBaseline: 'top' | 'middle' | 'bottom';\n layoutDirection: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n top: string;\n bottom: string;\n };\n isWidthMax: boolean;\n isHeightMax: boolean;\n singleLine: boolean;\n icons: Map<string, IRichTextIcon>;\n draw: (\n ctx: IContext2d,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => boolean;\n getActualSize: () => {\n width: number;\n height: number;\n };\n getRawActualSize: () => {\n width: number;\n height: number;\n };\n getActualSizeWidthEllipsis: () => {\n width: number;\n height: number;\n };\n}\n\nexport interface IRichText extends IGraphic<IRichTextGraphicAttribute> {\n getFrameCache: () => IRichTextFrame;\n}\n\nexport interface IRichTextIcon extends IImage {\n attribute: IRichTextIconGraphicAttribute;\n richtextId?: string;\n globalX?: number;\n globalY?: number;\n\n _x: number;\n _y: number;\n _hovered: boolean;\n _marginArray: [number, number, number, number];\n\n setHoverState: (hovered: boolean) => void;\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/richText.ts"],"names":[],"mappings":"","file":"richText.js","sourcesContent":["import type { IColor } from '../color';\nimport type { IContext2d } from '../context';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { IImage, IImageGraphicAttribute } from './image';\nimport type { ITextGraphicAttribute } from './text';\n\nexport type IRichTextAttribute = {\n width: number;\n height: number;\n ellipsis: boolean | string;\n wordBreak: RichTextWordBreak;\n verticalDirection: RichTextVerticalDirection;\n maxHeight: number;\n maxWidth: number;\n textAlign: RichTextGlobalAlignType;\n textBaseline: RichTextGlobalBaselineType;\n layoutDirection: RichTextLayoutDirectionType;\n textConfig: IRichTextCharacter[];\n // 是否不自动每行截断\n disableAutoWrapLine: boolean;\n singleLine: boolean;\n};\n\nexport type IRichTextGraphicAttribute = Partial<IGraphicAttribute & ITextGraphicAttribute> &\n Partial<IRichTextAttribute>;\n\nexport type RichTextWordBreak = 'break-word' | 'break-all';\nexport type RichTextVerticalDirection = 'top' | 'middle' | 'bottom';\nexport type RichTextGlobalAlignType = 'left' | 'right' | 'center';\nexport type RichTextGlobalBaselineType = 'top' | 'middle' | 'bottom';\nexport type RichTextLayoutDirectionType = 'horizontal' | 'vertical';\nexport type RichTextFontStyle = 'normal' | 'italic' | 'oblique';\nexport type RichTextTextDecoration = 'none' | 'underline' | 'line-through';\n// export type RichTextTextAlign = 'left' | 'right' | 'center';\nexport type RichTextScript = 'normal' | 'sub' | 'super';\n\nexport type IRichTextBasicCharacter = {\n lineHeight?: number | string;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextParagraphCharacter = IRichTextBasicCharacter & {\n text: string | number;\n fontSize?: number;\n fontFamily?: string;\n fill?: IColor | boolean;\n stroke?: IColor | boolean;\n fontWeight?: string;\n lineWidth?: number;\n // lineHeight?: number;\n fontStyle?: RichTextFontStyle; // normal, italic, oblique\n textDecoration?: RichTextTextDecoration; // none, underline, line-through\n // textAlign?: RichTextTextAlign; // left, right, center\n script?: RichTextScript; // normal, sub, super\n underline?: boolean;\n lineThrough?: boolean;\n opacity?: number;\n fillOpacity?: number;\n strokeOpacity?: number;\n // direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextImageCharacter = IRichTextBasicCharacter & {\n // 图片基础属性\n image: string | HTMLImageElement | HTMLCanvasElement;\n width: number;\n height: number;\n\n // hover相关属性\n // backgroundShow?: boolean; // 是否显示background\n backgroundShowMode?: 'always' | 'hover';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n // background size 同时控制了该icon的响应范围\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // 唯一标识符\n id?: string;\n\n // lineHeight?: number;\n // textAlign?: RichTextTextAlign; // left, right, center\n // direction?: RichTextLayoutDirectionType;\n margin?: number | number[];\n\n funcType?: string;\n hoverImage?: string | HTMLImageElement | HTMLCanvasElement;\n};\n\nexport type IRichTextCharacter = IRichTextParagraphCharacter | IRichTextImageCharacter;\n\nexport type IRichTextIconGraphicAttribute = IImageGraphicAttribute & {\n id?: string;\n backgroundShowMode?: 'always' | 'hover' | 'never';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // lineHeight?: number;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n\n margin?: number | number[];\n\n // backgroundShow?: boolean;\n};\n\nexport interface IRichTextParagraph {\n text: string;\n ascent: number;\n descent: number;\n width: number;\n height: number;\n lineHeight: number;\n fontSize: number;\n length: number;\n newLine: boolean;\n character: IRichTextParagraphCharacter;\n left: number;\n top: number;\n direction?: 'horizontal' | 'vertical';\n widthOrigin?: number;\n heightOrigin?: number;\n textBaseline?: CanvasTextBaseline;\n ellipsis: 'normal' | 'add' | 'replace' | 'hide';\n ellipsisWidth: number;\n ellipsisOtherParagraphWidth: number;\n verticalEllipsis?: boolean;\n updateWidth: () => void;\n draw: (ctx: IContext2d, baseline: number, deltaLeft: number, isLineFirst: boolean, textAlign: string) => void;\n getWidthWithEllips: (direction: string) => number;\n}\n\nexport interface IRichTextLine {\n left: number;\n top: number;\n width: number;\n height: number;\n baseline: number;\n ascent: number;\n descent: number;\n paragraphs: (IRichTextParagraph | IRichTextIcon)[];\n actualWidth: number;\n blankWidth: number;\n textAlign: string;\n direction: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n x: string;\n y: string;\n };\n draw: (\n ctx: IContext2d,\n lastLine: boolean,\n x: number,\n y: number,\n drawEllipsis: boolean | string,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => void;\n getWidthWithEllips: (ellipsis: string) => number;\n}\n\nexport interface IRichTextFrame {\n left: number;\n top: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n actualHeight: number;\n ellipsis: boolean | string;\n wordBreak: 'break-word' | 'break-all';\n verticalDirection: 'top' | 'middle' | 'bottom';\n lines: IRichTextLine[];\n globalAlign: 'left' | 'center' | 'right' | 'start' | 'end';\n globalBaseline: 'top' | 'middle' | 'bottom';\n layoutDirection: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n top: string;\n bottom: string;\n };\n isWidthMax: boolean;\n isHeightMax: boolean;\n singleLine: boolean;\n icons: Map<string, IRichTextIcon>;\n draw: (\n ctx: IContext2d,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => boolean;\n getActualSize: () => {\n width: number;\n height: number;\n };\n getRawActualSize: () => {\n width: number;\n height: number;\n };\n getActualSizeWidthEllipsis: () => {\n width: number;\n height: number;\n };\n}\n\nexport interface IRichText extends IGraphic<IRichTextGraphicAttribute> {\n getFrameCache: () => IRichTextFrame;\n}\n\nexport interface IRichTextIcon extends IImage {\n attribute: IRichTextIconGraphicAttribute;\n richtextId?: string;\n globalX?: number;\n globalY?: number;\n\n _x: number;\n _y: number;\n _hovered: boolean;\n _marginArray: [number, number, number, number];\n\n setHoverState: (hovered: boolean) => void;\n}\n"]}
@@ -9,14 +9,12 @@ import type { ILineGraphicAttribute } from './line';
9
9
  import type { IPathGraphicAttribute } from './path';
10
10
  import type { IPolygonGraphicAttribute } from './polygon';
11
11
  import type { IRectGraphicAttribute } from './rect';
12
- import type { IRect3dGraphicAttribute } from './rect3d';
13
12
  import type { IRichTextGraphicAttribute, IRichTextIconGraphicAttribute } from './richText';
14
13
  import type { ISymbolGraphicAttribute } from './symbol';
15
14
  import type { ITextGraphicAttribute } from './text';
16
15
  export interface IThemeSpec {
17
16
  text?: Partial<ITextGraphicAttribute>;
18
17
  rect?: Partial<IRectGraphicAttribute>;
19
- rect3d?: Partial<IRect3dGraphicAttribute>;
20
18
  arc?: Partial<IArcGraphicAttribute>;
21
19
  area?: Partial<IAreaGraphicAttribute>;
22
20
  circle?: Partial<ICircleGraphicAttribute>;
@@ -37,7 +35,6 @@ export interface IFullThemeSpec {
37
35
  symbol: Required<ISymbolGraphicAttribute>;
38
36
  text: Required<ITextGraphicAttribute>;
39
37
  rect: Required<IRectGraphicAttribute>;
40
- rect3d: Required<IRect3dGraphicAttribute>;
41
38
  glyph: Required<IGlyphGraphicAttribute>;
42
39
  group: Required<IGroupGraphicAttribute>;
43
40
  polygon: Required<IPolygonGraphicAttribute>;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { IGraphicAttribute } from '../graphic';\nimport type { IArcGraphicAttribute } from './arc';\nimport type { IAreaGraphicAttribute } from './area';\nimport type { ICircleGraphicAttribute } from './circle';\nimport type { IGlyphGraphicAttribute } from './glyph';\nimport type { IGroup, IGroupGraphicAttribute } from './group';\nimport type { IImageGraphicAttribute } from './image';\nimport type { ILineGraphicAttribute } from './line';\nimport type { IPathGraphicAttribute } from './path';\nimport type { IPolygonGraphicAttribute } from './polygon';\nimport type { IRectGraphicAttribute } from './rect';\nimport type { IRect3dGraphicAttribute } from './rect3d';\nimport type { IRichTextGraphicAttribute, IRichTextIconGraphicAttribute } from './richText';\nimport type { ISymbolGraphicAttribute } from './symbol';\nimport type { ITextGraphicAttribute } from './text';\n\nexport interface IThemeSpec {\n text?: Partial<ITextGraphicAttribute>;\n rect?: Partial<IRectGraphicAttribute>;\n rect3d?: Partial<IRect3dGraphicAttribute>;\n arc?: Partial<IArcGraphicAttribute>;\n area?: Partial<IAreaGraphicAttribute>;\n circle?: Partial<ICircleGraphicAttribute>;\n line?: Partial<ILineGraphicAttribute>;\n path?: Partial<IPathGraphicAttribute>;\n symbol?: Partial<ISymbolGraphicAttribute>;\n group?: Partial<IGroupGraphicAttribute>;\n polygon?: Partial<IPolygonGraphicAttribute>;\n image?: Partial<IImageGraphicAttribute>;\n common?: Partial<IGraphicAttribute>;\n}\n\nexport interface IFullThemeSpec {\n arc: Required<IArcGraphicAttribute>;\n area: Required<IAreaGraphicAttribute>;\n circle: Required<ICircleGraphicAttribute>;\n line: Required<ILineGraphicAttribute>;\n path: Required<IPathGraphicAttribute>;\n symbol: Required<ISymbolGraphicAttribute>;\n text: Required<ITextGraphicAttribute>;\n rect: Required<IRectGraphicAttribute>;\n rect3d: Required<IRect3dGraphicAttribute>;\n glyph: Required<IGlyphGraphicAttribute>;\n group: Required<IGroupGraphicAttribute>;\n polygon: Required<IPolygonGraphicAttribute>;\n richtext: Required<IRichTextGraphicAttribute>;\n richtextIcon: Required<IRichTextIconGraphicAttribute>;\n image: Required<IImageGraphicAttribute>;\n}\n\nexport interface ITheme {\n getTheme: (g: IGroup) => IFullThemeSpec;\n combinedTheme?: IFullThemeSpec;\n userTheme?: IThemeSpec;\n nextTheme?: IThemeSpec;\n applyTheme: (group: IGroup, pt: IThemeSpec, force?: boolean) => IThemeSpec;\n setTheme: (t: IThemeSpec, g: IGroup) => void;\n dirty: boolean;\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { IGraphicAttribute } from '../graphic';\nimport type { IArcGraphicAttribute } from './arc';\nimport type { IAreaGraphicAttribute } from './area';\nimport type { ICircleGraphicAttribute } from './circle';\nimport type { IGlyphGraphicAttribute } from './glyph';\nimport type { IGroup, IGroupGraphicAttribute } from './group';\nimport type { IImageGraphicAttribute } from './image';\nimport type { ILineGraphicAttribute } from './line';\nimport type { IPathGraphicAttribute } from './path';\nimport type { IPolygonGraphicAttribute } from './polygon';\nimport type { IRectGraphicAttribute } from './rect';\nimport type { IRichTextGraphicAttribute, IRichTextIconGraphicAttribute } from './richText';\nimport type { ISymbolGraphicAttribute } from './symbol';\nimport type { ITextGraphicAttribute } from './text';\n\nexport interface IThemeSpec {\n text?: Partial<ITextGraphicAttribute>;\n rect?: Partial<IRectGraphicAttribute>;\n arc?: Partial<IArcGraphicAttribute>;\n area?: Partial<IAreaGraphicAttribute>;\n circle?: Partial<ICircleGraphicAttribute>;\n line?: Partial<ILineGraphicAttribute>;\n path?: Partial<IPathGraphicAttribute>;\n symbol?: Partial<ISymbolGraphicAttribute>;\n group?: Partial<IGroupGraphicAttribute>;\n polygon?: Partial<IPolygonGraphicAttribute>;\n image?: Partial<IImageGraphicAttribute>;\n common?: Partial<IGraphicAttribute>;\n}\n\nexport interface IFullThemeSpec {\n arc: Required<IArcGraphicAttribute>;\n area: Required<IAreaGraphicAttribute>;\n circle: Required<ICircleGraphicAttribute>;\n line: Required<ILineGraphicAttribute>;\n path: Required<IPathGraphicAttribute>;\n symbol: Required<ISymbolGraphicAttribute>;\n text: Required<ITextGraphicAttribute>;\n rect: Required<IRectGraphicAttribute>;\n glyph: Required<IGlyphGraphicAttribute>;\n group: Required<IGroupGraphicAttribute>;\n polygon: Required<IPolygonGraphicAttribute>;\n richtext: Required<IRichTextGraphicAttribute>;\n richtextIcon: Required<IRichTextIconGraphicAttribute>;\n image: Required<IImageGraphicAttribute>;\n}\n\nexport interface ITheme {\n getTheme: (g: IGroup) => IFullThemeSpec;\n combinedTheme?: IFullThemeSpec;\n userTheme?: IThemeSpec;\n nextTheme?: IThemeSpec;\n applyTheme: (group: IGroup, pt: IThemeSpec, force?: boolean) => IThemeSpec;\n setTheme: (t: IThemeSpec, g: IGroup) => void;\n dirty: boolean;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { IAABBBounds, IOBBBounds, IMatrix, IPointLike, IPoint } from '@visactor/vutils';
1
+ import type { IAABBBounds, IOBBBounds, IMatrix, IPointLike, IPoint, BoundsAnchorType } from '@visactor/vutils';
2
2
  import type { IAnimate, IStep, EasingType, IAnimateTarget } from './animate';
3
3
  import type { IColor } from './color';
4
4
  import type { IGroup } from './graphic/group';
@@ -94,7 +94,26 @@ export type IBackgroundConfig = {
94
94
  expandY?: number;
95
95
  };
96
96
  type IBackgroundType = string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig;
97
+ export interface SimpleDomStyleOptions {
98
+ width: number;
99
+ height: number;
100
+ style?: string | Record<string, any> | ((pos: {
101
+ top: number;
102
+ left: number;
103
+ width: number;
104
+ height: number;
105
+ }, graphic: IGraphic, wrapContainer: HTMLElement) => Record<string, any>);
106
+ }
107
+ export interface CommonDomOptions {
108
+ id?: string;
109
+ container: string | HTMLElement | null;
110
+ visible?: boolean;
111
+ pointerEvents?: boolean | string;
112
+ anchorType?: 'position' | 'boundsLeftTop' | BoundsAnchorType;
113
+ }
97
114
  export type IGraphicStyle = ILayout & IFillStyle & IStrokeStyle & IPickStyle & {
115
+ forceBoundsWidth: number | (() => number) | undefined;
116
+ forceBoundsHeight: number | (() => number) | undefined;
98
117
  opacity: number;
99
118
  backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
100
119
  backgroundFit: boolean;
@@ -116,26 +135,12 @@ export type IGraphicStyle = ILayout & IFillStyle & IStrokeStyle & IPickStyle & {
116
135
  blur: number;
117
136
  cursor: Cursor | null;
118
137
  renderStyle?: 'default' | 'rough' | any;
119
- html: {
138
+ html: ({
120
139
  dom: string | HTMLElement;
121
- container: string | HTMLElement | null;
122
- width: number;
123
- height: number;
124
- style?: string | Record<string, any>;
125
- visible?: boolean;
126
- pointerEvents?: boolean;
127
- anchorType?: 'position' | 'boundsLeftTop';
128
- } | null;
129
- react: {
140
+ } & SimpleDomStyleOptions & CommonDomOptions) | null;
141
+ react: ({
130
142
  element: any;
131
- container: string | HTMLElement | null;
132
- width: number;
133
- height: number;
134
- style?: string | Record<string, any>;
135
- visible?: boolean;
136
- pointerEvents?: boolean;
137
- anchorType?: 'position' | 'boundsLeftTop';
138
- } | null;
143
+ } & SimpleDomStyleOptions & CommonDomOptions) | null;
139
144
  };
140
145
  export type IPickStyle = {
141
146
  pickStrokeBuffer: number;
@@ -156,6 +161,7 @@ export type IGraphicAttribute = IDebugType & IGraphicStyle & ITransform & {
156
161
  visible: boolean;
157
162
  zIndex: number;
158
163
  layout: any;
164
+ renderable: boolean;
159
165
  keepDirIn3d?: boolean;
160
166
  shadowRootIdx: number;
161
167
  globalZIndex: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic.ts"],"names":[],"mappings":"","file":"graphic.js","sourcesContent":["import type { IAABBBounds, IOBBBounds, IMatrix, IPointLike, IPoint } from '@visactor/vutils';\nimport type { IAnimate, IStep, EasingType, IAnimateTarget } from './animate';\nimport type { IColor } from './color';\nimport type { IGroup } from './graphic/group';\nimport type { IShadowRoot } from './graphic/shadow-root';\nimport type { ILayer } from './layer';\nimport type { INode } from './node-tree';\nimport type { ICustomPath2D } from './path';\nimport type { IStage } from './stage';\nimport type { IGlyphGraphicAttribute } from './graphic/glyph';\nimport type { IContainPointMode } from '../common/enums';\nimport type { IFace3d } from './graphic/face3d';\nimport type { IPickerService } from './picker';\nimport { ITheme } from './graphic/theme';\n\ntype IStrokeSeg = {\n start: number; // 百分比\n // end和length二选一\n end: number; // 百分比\n length: number; // 像素长度\n};\n\n// TODO 最后加一个any\nexport type GraphicType =\n | 'area'\n | 'circle'\n | 'ellipse'\n | 'line'\n | 'rect'\n | 'rect3d'\n | 'path'\n | 'richtext'\n | 'text'\n | 'arc'\n | 'arc3d'\n | 'image'\n | 'symbol'\n | 'group'\n | 'shadowroot'\n | 'polygon'\n | 'pyramid3d'\n | 'glyph';\n\n// Cursor style\n// See: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor\nexport type Cursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out';\n\nexport type ITransform = {\n x: number;\n y: number;\n z: number;\n dx: number;\n dy: number;\n dz: number;\n scrollX: number;\n scrollY: number;\n scaleX: number;\n scaleY: number;\n scaleZ: number;\n angle: number;\n alpha: number;\n beta: number;\n scaleCenter: [number | string, number | string];\n anchor: [number | string, number | string]; // 基于AABB的锚点位置,用于简单的定位某些path\n anchor3d: [number | string, number | string, number] | [number | string, number | string]; // 3d的锚点位置\n postMatrix: IMatrix;\n};\n\nexport type IFillType = boolean | string | IColor;\nexport type IFillStyle = {\n fillOpacity: number;\n shadowBlur: number;\n shadowColor: string;\n shadowOffsetX: number;\n shadowOffsetY: number;\n fill: IFillType;\n};\n\nexport type ILayout = {\n alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center';\n};\n\nexport type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {\n distance: number | string;\n visible?: boolean;\n};\n\nexport type IStrokeType = boolean | string | IColor | null;\nexport type IStrokeStyle = {\n outerBorder: Partial<IBorderStyle>;\n innerBorder: Partial<IBorderStyle>;\n strokeOpacity: number;\n lineDash: number[];\n lineDashOffset: number;\n lineWidth: number;\n lineCap: CanvasLineCap;\n lineJoin: CanvasLineJoin;\n miterLimit: number;\n // 描边的boundsBuffer,用于控制bounds的buffer\n strokeBoundsBuffer: number;\n /**\n * stroke - true 全描边\n * stroke - false 不描边\n * stroke 为数值类型,适用于rect\\arc等图形,用于配置部分描边的场景,其中\n *\n * 0b00000 - 不描边\n * 0b000001 - top\n * 0b000010 - right\n * 0b000100 - bottom\n * 0b001000 - left\n * 相应的:\n * 0b000011 - top + right\n * 0b000111 - top + right + bottom\n * 0b001111 - 全描边\n *\n * stroke - boolean[],适用于rect\\arc等图形,用于配置部分描边的场景\n */\n stroke: IStrokeType[] | IStrokeType;\n};\n\ntype TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';\n\nexport type IConnectedStyle = {\n // 连接,取零或者断开\n connectedType: 'connect' | 'zero' | 'none';\n connectedStyle: {\n stroke: IStrokeStyle['stroke'];\n strokeOpacity: IStrokeStyle['strokeOpacity'];\n lineDash: IStrokeStyle['lineDash'];\n lineDashOffset: IStrokeStyle['lineDashOffset'];\n lineCap: IStrokeStyle['lineCap'];\n lineJoin: IStrokeStyle['lineJoin'];\n lineWidth: IStrokeStyle['lineWidth'];\n fill: IFillStyle['fill'];\n fillOpacity: IFillStyle['fillOpacity'];\n };\n connectedX: number;\n connectedY: number;\n};\n\nexport type IBackgroundConfig = {\n stroke?: string | boolean;\n fill?: string | boolean;\n lineWidth?: number;\n cornerRadius?: number;\n expandX?: number;\n expandY?: number;\n};\n\ntype IBackgroundType = string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig;\n\nexport type IGraphicStyle = ILayout &\n IFillStyle &\n IStrokeStyle &\n IPickStyle & {\n opacity: number;\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; // 填充模式(与具体图元有关)\n backgroundFit: boolean; // 是否正好填充,只在repeat-x或者repeat-y以及no-repeat的时候生效\n backgroundCornerRadius: number | number[];\n backgroundOpacity: number;\n background:\n | IBackgroundType\n | {\n background: IBackgroundType;\n dx?: number;\n dy?: number;\n width?: number;\n height?: number;\n x?: number;\n y?: number;\n }\n | null; // 背景,可以与fill同时存在\n texture: TextureType | string; // 纹理\n textureColor: string; // 纹理颜色\n textureSize: number; // 纹理大小\n texturePadding: number; // 纹理间隙\n blur: number;\n cursor: Cursor | null; // 鼠标样式\n renderStyle?: 'default' | 'rough' | any;\n // HTML的dom或者string\n html: {\n dom: string | HTMLElement; // dom字符串或者dom\n container: string | HTMLElement | null; // id或者dom\n width: number; // 容器的宽度\n height: number; // 容器的高度\n style?: string | Record<string, any>; // 容器的样式\n visible?: boolean;\n pointerEvents?: boolean;\n anchorType?: 'position' | 'boundsLeftTop';\n } | null;\n react: {\n element: any; // react场景节点\n container: string | HTMLElement | null; // id或者dom\n width: number; // 容器的宽度\n height: number; // 容器的高度\n style?: string | Record<string, any>; // 容器的样式\n visible?: boolean;\n pointerEvents?: boolean;\n anchorType?: 'position' | 'boundsLeftTop';\n } | null;\n };\n\nexport type IPickStyle = {\n // 给stroke模式的pick额外加的buffer,用于外界控制stroke区域的pick范围\n pickStrokeBuffer: number;\n};\n\nexport type IDebugType = {\n _debug_bounds: boolean | ((c: any, g: any) => void);\n};\nexport type IGraphicAttribute = IDebugType &\n IGraphicStyle &\n ITransform & {\n /**\n * stroke百分比\n */\n strokeSeg: IStrokeSeg | null;\n // 包围盒的padding\n boundsPadding: number | number[];\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode: 'accurate' | 'imprecise' | 'custom';\n boundsMode: 'accurate' | 'imprecise';\n customPickShape: () => boolean | null;\n /**\n * 是否支持事件拾取,默认为 true。\n * @default true\n */\n pickable: boolean;\n /**\n * 是否支持fill拾取,默认为 true。\n * @experimental\n * @default true\n */\n fillPickable: boolean;\n /**\n * 是否支持stroke拾取,默认为 true。\n * @experimental\n * @default true\n */\n strokePickable: boolean;\n /**\n * 对于 group 节点,是否支持其子元素的事件拾取,默认为 true。\n * 如果 group `pickable` 关闭,`childrenPickable` 开启,那么 group 的子节点仍参与事件拾取\n * @default true\n */\n childrenPickable: boolean;\n /**\n * 元素是否可见。\n * @default true\n */\n visible: boolean;\n zIndex: number;\n layout: any;\n /**\n * 是否在3d中控制方向\n * false: 不控制方向\n * true: 始终控制方向朝摄像机\n */\n keepDirIn3d?: boolean;\n shadowRootIdx: number;\n globalZIndex: number;\n globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'] | '';\n // 完全支持滚动 | 完全不支持滚动 | 支持x方向的滚动 | 支持y方向的滚动\n overflow: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';\n };\n\nexport interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {\n attribute: Partial<T>;\n _uid: number;\n type: string;\n name: string;\n children: IGraphicJson<T>[];\n}\n\n/** the context of setAttribute */\nexport type ISetAttributeContext = {\n /** type of setAttribute */\n type?: number;\n animationState?: {\n step?: IStep;\n isFirstFrameOfStep?: boolean;\n /** ratio of animation */\n ratio?: number;\n /** is animation end? */\n end?: boolean;\n };\n skipUpdateCallback?: boolean;\n};\n\nexport type IGraphicAnimateParams = {\n id?: number | string;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n};\n\nexport interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>>\n extends INode,\n IAnimateTarget {\n type?: GraphicType;\n numberType?: number;\n stage?: IStage;\n layer?: ILayer;\n shadowRoot?: IShadowRoot;\n glyphHost?: IGraphic<IGlyphGraphicAttribute>;\n backgroundImg?: boolean;\n attachedThemeGraphic?: IGraphic<any>;\n\n bindDom?: Map<\n string | HTMLElement,\n { container: HTMLElement | string; dom: HTMLElement | any; wrapGroup: HTMLDivElement | any; root?: any }\n >;\n\n valid: boolean;\n parent: IGroup | null;\n isContainer?: boolean;\n // 是否是3d模式(是否应用3d视角)\n in3dMode?: boolean;\n\n // 上次更新的stamp\n stamp?: number;\n animationBackUps?: {\n from: Record<string, any>;\n to: Record<string, any>;\n };\n\n attribute: Partial<T>;\n\n /** 用于实现morph动画场景,转换成bezier曲线渲染 */\n pathProxy?: ICustomPath2D | ((attrs: T) => ICustomPath2D);\n incremental?: number;\n incrementalAt?: number;\n\n /** 记录state对应的图形属性 */\n states?: Record<string, Partial<T>>;\n normalAttrs?: Partial<T>;\n stateProxy?: (stateName: string, targetStates?: string[]) => Partial<T>;\n findFace?: () => IFace3d;\n toggleState: (stateName: string, hasAnimation?: boolean) => void;\n removeState: (stateName: string, hasAnimation?: boolean) => void;\n clearStates: (hasAnimation?: boolean) => void;\n useStates: (states: string[], hasAnimation?: boolean) => void;\n addState: (stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean) => void;\n hasState: (stateName?: string) => boolean;\n getState: (stateName: string) => Partial<T>;\n onBeforeAttributeUpdate?: (\n val: any,\n attributes: Partial<T>,\n key: null | string | string[],\n context?: ISetAttributeContext\n ) => T | undefined;\n applyStateAttrs: (attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean) => void;\n updateNormalAttrs: (stateAttrs: Partial<T>) => void;\n\n // get\n readonly AABBBounds: IAABBBounds; // 用于获取当前节点的AABB包围盒\n readonly OBBBounds: IOBBBounds; // 获取OBB包围盒,旋转防重叠需要用\n readonly globalAABBBounds: IAABBBounds; // 全局AABB包围盒\n readonly transMatrix: IMatrix; // 变换矩阵,动态计算\n readonly globalTransMatrix: IMatrix; // 变换矩阵,动态计算\n\n getOffsetXY: (attr?: ITransform) => IPoint;\n\n // function\n containsPoint: (x: number, y: number, mode?: IContainPointMode, picker?: IPickerService) => boolean;\n\n setMode: (mode: '3d' | '2d') => void;\n isValid: () => boolean;\n\n // TODO: transform API\n // 基于当前transform的变换,普通用户尽量别用,拿捏不住的~\n translate: (x: number, y: number) => this;\n translateTo: (x: number, y: number) => this;\n scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;\n scaleTo: (scaleX: number, scaleY: number) => this;\n rotate: (angle: number, rotateCenter?: IPointLike) => this;\n rotateTo: (angle: number) => this;\n skewTo: (b: number, c: number) => this;\n addUpdateBoundTag: () => void;\n addUpdateShapeAndBoundsTag: () => void;\n addUpdateLayoutTag: () => void;\n\n update: (d?: { bounds: boolean; trans: boolean }) => void;\n\n // animate\n animate: (params?: IGraphicAnimateParams) => IAnimate;\n\n // 语法糖,可有可无,有的为了首屏性能考虑做成get方法,有的由外界直接托管,内部不赋值\n name?: string;\n\n // 供render处理shape缓存tag\n shouldUpdateShape: () => boolean;\n clearUpdateShapeTag: () => void;\n\n // // 供render缓存shape\n // cacheShape?: ICustomPath2D;\n // // 线段使用的path2D\n // cacheLine?: ISegPath2D | ISegPath2D[];\n // // 面积图使用的path2D\n // cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n\n setAttributes: (params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n initAttributes: (params: Partial<T>) => void;\n\n setAttribute: (key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n setStage: (stage?: IStage, layer?: ILayer) => void;\n onSetStage: (cb: (g: IGraphic, stage: IStage) => void) => void;\n\n shouldUpdateAABBBounds: () => boolean;\n shouldSelfChangeUpdateAABBBounds: () => boolean;\n shouldUpdateGlobalMatrix: () => boolean;\n\n addUpdatePositionTag: () => void;\n addUpdateGlobalPositionTag: () => void;\n\n attachShadow: () => IShadowRoot;\n detachShadow: () => void;\n\n toJson: () => IGraphicJson;\n\n /** 创建pathProxy */\n createPathProxy: (path?: string) => void;\n /** 将图形转换成CustomPath2D */\n toCustomPath?: () => ICustomPath2D;\n\n resources?: Map<\n string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig,\n { state: 'init' | 'loading' | 'success' | 'fail'; data?: HTMLImageElement | HTMLCanvasElement }\n >;\n imageLoadSuccess: (url: string, data: HTMLImageElement) => void;\n imageLoadFail: (url: string) => void;\n\n clone: () => IGraphic;\n stopAnimates: (stopChildren?: boolean) => void;\n getNoWorkAnimateAttr: () => Record<string, number>;\n}\n\nexport interface IRoot extends IGraphic {\n pick: (x: number, y: number) => IGraphic;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimateConfig = {\n duration?: number;\n easing?: EasingType;\n};\n\nexport type GraphicReleaseStatus = 'released' | 'willRelease';\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic.ts"],"names":[],"mappings":"","file":"graphic.js","sourcesContent":["import type { IAABBBounds, IOBBBounds, IMatrix, IPointLike, IPoint, BoundsAnchorType } from '@visactor/vutils';\nimport type { IAnimate, IStep, EasingType, IAnimateTarget } from './animate';\nimport type { IColor } from './color';\nimport type { IGroup } from './graphic/group';\nimport type { IShadowRoot } from './graphic/shadow-root';\nimport type { ILayer } from './layer';\nimport type { INode } from './node-tree';\nimport type { ICustomPath2D } from './path';\nimport type { IStage } from './stage';\nimport type { IGlyphGraphicAttribute } from './graphic/glyph';\nimport type { IContainPointMode } from '../common/enums';\nimport type { IFace3d } from './graphic/face3d';\nimport type { IPickerService } from './picker';\n\ntype IStrokeSeg = {\n start: number; // 百分比\n // end和length二选一\n end: number; // 百分比\n length: number; // 像素长度\n};\n\n// TODO 最后加一个any\nexport type GraphicType =\n | 'area'\n | 'circle'\n | 'ellipse'\n | 'line'\n | 'rect'\n | 'rect3d'\n | 'path'\n | 'richtext'\n | 'text'\n | 'arc'\n | 'arc3d'\n | 'image'\n | 'symbol'\n | 'group'\n | 'shadowroot'\n | 'polygon'\n | 'pyramid3d'\n | 'glyph';\n\n// Cursor style\n// See: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor\nexport type Cursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out';\n\nexport type ITransform = {\n x: number;\n y: number;\n z: number;\n dx: number;\n dy: number;\n dz: number;\n scrollX: number;\n scrollY: number;\n scaleX: number;\n scaleY: number;\n scaleZ: number;\n angle: number;\n alpha: number;\n beta: number;\n scaleCenter: [number | string, number | string];\n anchor: [number | string, number | string]; // 基于AABB的锚点位置,用于简单的定位某些path\n anchor3d: [number | string, number | string, number] | [number | string, number | string]; // 3d的锚点位置\n postMatrix: IMatrix;\n};\n\nexport type IFillType = boolean | string | IColor;\nexport type IFillStyle = {\n fillOpacity: number;\n shadowBlur: number;\n shadowColor: string;\n shadowOffsetX: number;\n shadowOffsetY: number;\n fill: IFillType;\n};\n\nexport type ILayout = {\n alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center';\n};\n\nexport type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {\n distance: number | string;\n visible?: boolean;\n};\n\nexport type IStrokeType = boolean | string | IColor | null;\nexport type IStrokeStyle = {\n outerBorder: Partial<IBorderStyle>;\n innerBorder: Partial<IBorderStyle>;\n strokeOpacity: number;\n lineDash: number[];\n lineDashOffset: number;\n lineWidth: number;\n lineCap: CanvasLineCap;\n lineJoin: CanvasLineJoin;\n miterLimit: number;\n // 描边的boundsBuffer,用于控制bounds的buffer\n strokeBoundsBuffer: number;\n /**\n * stroke - true 全描边\n * stroke - false 不描边\n * stroke 为数值类型,适用于rect\\arc等图形,用于配置部分描边的场景,其中\n *\n * 0b00000 - 不描边\n * 0b000001 - top\n * 0b000010 - right\n * 0b000100 - bottom\n * 0b001000 - left\n * 相应的:\n * 0b000011 - top + right\n * 0b000111 - top + right + bottom\n * 0b001111 - 全描边\n *\n * stroke - boolean[],适用于rect\\arc等图形,用于配置部分描边的场景\n */\n stroke: IStrokeType[] | IStrokeType;\n};\n\ntype TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';\n\nexport type IConnectedStyle = {\n // 连接,取零或者断开\n connectedType: 'connect' | 'zero' | 'none';\n connectedStyle: {\n stroke: IStrokeStyle['stroke'];\n strokeOpacity: IStrokeStyle['strokeOpacity'];\n lineDash: IStrokeStyle['lineDash'];\n lineDashOffset: IStrokeStyle['lineDashOffset'];\n lineCap: IStrokeStyle['lineCap'];\n lineJoin: IStrokeStyle['lineJoin'];\n lineWidth: IStrokeStyle['lineWidth'];\n fill: IFillStyle['fill'];\n fillOpacity: IFillStyle['fillOpacity'];\n };\n connectedX: number;\n connectedY: number;\n};\n\nexport type IBackgroundConfig = {\n stroke?: string | boolean;\n fill?: string | boolean;\n lineWidth?: number;\n cornerRadius?: number;\n expandX?: number;\n expandY?: number;\n};\n\ntype IBackgroundType = string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig;\n\nexport interface SimpleDomStyleOptions {\n width: number; // 容器的宽度\n height: number; // 容器的高度\n style?:\n | string\n | Record<string, any>\n | ((\n pos: { top: number; left: number; width: number; height: number },\n graphic: IGraphic,\n wrapContainer: HTMLElement\n ) => Record<string, any>); // 容器的样式\n}\n\nexport interface CommonDomOptions {\n id?: string;\n container: string | HTMLElement | null; // id或者dom\n visible?: boolean;\n pointerEvents?: boolean | string;\n anchorType?: 'position' | 'boundsLeftTop' | BoundsAnchorType;\n}\n\nexport type IGraphicStyle = ILayout &\n IFillStyle &\n IStrokeStyle &\n IPickStyle & {\n forceBoundsWidth: number | (() => number) | undefined;\n forceBoundsHeight: number | (() => number) | undefined;\n opacity: number;\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; // 填充模式(与具体图元有关)\n backgroundFit: boolean; // 是否正好填充,只在repeat-x或者repeat-y以及no-repeat的时候生效\n backgroundCornerRadius: number | number[];\n backgroundOpacity: number;\n background:\n | IBackgroundType\n | {\n background: IBackgroundType;\n dx?: number;\n dy?: number;\n width?: number;\n height?: number;\n x?: number;\n y?: number;\n }\n | null; // 背景,可以与fill同时存在\n texture: TextureType | string; // 纹理\n textureColor: string; // 纹理颜色\n textureSize: number; // 纹理大小\n texturePadding: number; // 纹理间隙\n blur: number;\n cursor: Cursor | null; // 鼠标样式\n renderStyle?: 'default' | 'rough' | any;\n // HTML的dom或者string\n html:\n | ({\n dom: string | HTMLElement; // dom字符串或者dom\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n react:\n | ({\n element: any; // react场景节点\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n };\n\nexport type IPickStyle = {\n // 给stroke模式的pick额外加的buffer,用于外界控制stroke区域的pick范围\n pickStrokeBuffer: number;\n};\n\nexport type IDebugType = {\n _debug_bounds: boolean | ((c: any, g: any) => void);\n};\nexport type IGraphicAttribute = IDebugType &\n IGraphicStyle &\n ITransform & {\n /**\n * stroke百分比\n */\n strokeSeg: IStrokeSeg | null;\n // 包围盒的padding\n boundsPadding: number | number[];\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode: 'accurate' | 'imprecise' | 'custom';\n boundsMode: 'accurate' | 'imprecise';\n customPickShape: () => boolean | null;\n /**\n * 是否支持事件拾取,默认为 true。\n * @default true\n */\n pickable: boolean;\n /**\n * 是否支持fill拾取,默认为 true。\n * @experimental\n * @default true\n */\n fillPickable: boolean;\n /**\n * 是否支持stroke拾取,默认为 true。\n * @experimental\n * @default true\n */\n strokePickable: boolean;\n /**\n * 对于 group 节点,是否支持其子元素的事件拾取,默认为 true。\n * 如果 group `pickable` 关闭,`childrenPickable` 开启,那么 group 的子节点仍参与事件拾取\n * @default true\n */\n childrenPickable: boolean;\n /**\n * 元素是否可见。\n * @default true\n */\n visible: boolean;\n zIndex: number;\n layout: any;\n /**\n * 是否隐藏元素(只是绘制的时候不绘制)\n */\n renderable: boolean;\n /**\n * 是否在3d中控制方向\n * false: 不控制方向\n * true: 始终控制方向朝摄像机\n */\n keepDirIn3d?: boolean;\n shadowRootIdx: number;\n globalZIndex: number;\n globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'] | '';\n // 完全支持滚动 | 完全不支持滚动 | 支持x方向的滚动 | 支持y方向的滚动\n overflow: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';\n };\n\nexport interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {\n attribute: Partial<T>;\n _uid: number;\n type: string;\n name: string;\n children: IGraphicJson<T>[];\n}\n\n/** the context of setAttribute */\nexport type ISetAttributeContext = {\n /** type of setAttribute */\n type?: number;\n animationState?: {\n step?: IStep;\n isFirstFrameOfStep?: boolean;\n /** ratio of animation */\n ratio?: number;\n /** is animation end? */\n end?: boolean;\n };\n skipUpdateCallback?: boolean;\n};\n\nexport type IGraphicAnimateParams = {\n id?: number | string;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n};\n\nexport interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>>\n extends INode,\n IAnimateTarget {\n type?: GraphicType;\n numberType?: number;\n stage?: IStage;\n layer?: ILayer;\n shadowRoot?: IShadowRoot;\n glyphHost?: IGraphic<IGlyphGraphicAttribute>;\n backgroundImg?: boolean;\n attachedThemeGraphic?: IGraphic<any>;\n\n bindDom?: Map<\n string | HTMLElement,\n { container: HTMLElement | string; dom: HTMLElement | any; wrapGroup: HTMLDivElement | any; root?: any }\n >;\n\n valid: boolean;\n parent: IGroup | null;\n isContainer?: boolean;\n // 是否是3d模式(是否应用3d视角)\n in3dMode?: boolean;\n\n // 上次更新的stamp\n stamp?: number;\n animationBackUps?: {\n from: Record<string, any>;\n to: Record<string, any>;\n };\n\n attribute: Partial<T>;\n\n /** 用于实现morph动画场景,转换成bezier曲线渲染 */\n pathProxy?: ICustomPath2D | ((attrs: T) => ICustomPath2D);\n incremental?: number;\n incrementalAt?: number;\n\n /** 记录state对应的图形属性 */\n states?: Record<string, Partial<T>>;\n normalAttrs?: Partial<T>;\n stateProxy?: (stateName: string, targetStates?: string[]) => Partial<T>;\n findFace?: () => IFace3d;\n toggleState: (stateName: string, hasAnimation?: boolean) => void;\n removeState: (stateName: string, hasAnimation?: boolean) => void;\n clearStates: (hasAnimation?: boolean) => void;\n useStates: (states: string[], hasAnimation?: boolean) => void;\n addState: (stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean) => void;\n hasState: (stateName?: string) => boolean;\n getState: (stateName: string) => Partial<T>;\n onBeforeAttributeUpdate?: (\n val: any,\n attributes: Partial<T>,\n key: null | string | string[],\n context?: ISetAttributeContext\n ) => T | undefined;\n applyStateAttrs: (attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean) => void;\n updateNormalAttrs: (stateAttrs: Partial<T>) => void;\n\n // get\n readonly AABBBounds: IAABBBounds; // 用于获取当前节点的AABB包围盒\n readonly OBBBounds: IOBBBounds; // 获取OBB包围盒,旋转防重叠需要用\n readonly globalAABBBounds: IAABBBounds; // 全局AABB包围盒\n readonly transMatrix: IMatrix; // 变换矩阵,动态计算\n readonly globalTransMatrix: IMatrix; // 变换矩阵,动态计算\n\n getOffsetXY: (attr?: ITransform) => IPoint;\n\n // function\n containsPoint: (x: number, y: number, mode?: IContainPointMode, picker?: IPickerService) => boolean;\n\n setMode: (mode: '3d' | '2d') => void;\n isValid: () => boolean;\n\n // TODO: transform API\n // 基于当前transform的变换,普通用户尽量别用,拿捏不住的~\n translate: (x: number, y: number) => this;\n translateTo: (x: number, y: number) => this;\n scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;\n scaleTo: (scaleX: number, scaleY: number) => this;\n rotate: (angle: number, rotateCenter?: IPointLike) => this;\n rotateTo: (angle: number) => this;\n skewTo: (b: number, c: number) => this;\n addUpdateBoundTag: () => void;\n addUpdateShapeAndBoundsTag: () => void;\n addUpdateLayoutTag: () => void;\n\n update: (d?: { bounds: boolean; trans: boolean }) => void;\n\n // animate\n animate: (params?: IGraphicAnimateParams) => IAnimate;\n\n // 语法糖,可有可无,有的为了首屏性能考虑做成get方法,有的由外界直接托管,内部不赋值\n name?: string;\n\n // 供render处理shape缓存tag\n shouldUpdateShape: () => boolean;\n clearUpdateShapeTag: () => void;\n\n // // 供render缓存shape\n // cacheShape?: ICustomPath2D;\n // // 线段使用的path2D\n // cacheLine?: ISegPath2D | ISegPath2D[];\n // // 面积图使用的path2D\n // cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n\n setAttributes: (params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n initAttributes: (params: Partial<T>) => void;\n\n setAttribute: (key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n setStage: (stage?: IStage, layer?: ILayer) => void;\n onSetStage: (cb: (g: IGraphic, stage: IStage) => void) => void;\n\n shouldUpdateAABBBounds: () => boolean;\n shouldSelfChangeUpdateAABBBounds: () => boolean;\n shouldUpdateGlobalMatrix: () => boolean;\n\n addUpdatePositionTag: () => void;\n addUpdateGlobalPositionTag: () => void;\n\n attachShadow: () => IShadowRoot;\n detachShadow: () => void;\n\n toJson: () => IGraphicJson;\n\n /** 创建pathProxy */\n createPathProxy: (path?: string) => void;\n /** 将图形转换成CustomPath2D */\n toCustomPath?: () => ICustomPath2D;\n\n resources?: Map<\n string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig,\n { state: 'init' | 'loading' | 'success' | 'fail'; data?: HTMLImageElement | HTMLCanvasElement }\n >;\n imageLoadSuccess: (url: string, data: HTMLImageElement) => void;\n imageLoadFail: (url: string) => void;\n\n clone: () => IGraphic;\n stopAnimates: (stopChildren?: boolean) => void;\n getNoWorkAnimateAttr: () => Record<string, number>;\n}\n\nexport interface IRoot extends IGraphic {\n pick: (x: number, y: number) => IGraphic;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimateConfig = {\n duration?: number;\n easing?: EasingType;\n};\n\nexport type GraphicReleaseStatus = 'released' | 'willRelease';\n"]}
@@ -14,6 +14,9 @@ import type { IWindow } from './window';
14
14
  import type { ILayerService } from './core';
15
15
  import type { IFullThemeSpec } from './graphic/theme';
16
16
  export type IExportType = 'canvas' | 'imageData';
17
+ export type IStageCreateContext = {
18
+ appName?: 'vchart' | 'vgrammar' | 'vtable' | string;
19
+ };
17
20
  export interface IStageParams {
18
21
  viewBox: IBoundsLike;
19
22
  width: number;
@@ -41,6 +44,7 @@ export interface IStageParams {
41
44
  event?: EventConfig;
42
45
  supportsTouchEvents?: boolean;
43
46
  supportsPointerEvents?: boolean;
47
+ context?: IStageCreateContext;
44
48
  }
45
49
  export type EventConfig = {
46
50
  autoPreventDefault?: boolean;
@@ -151,6 +155,10 @@ export interface IStage extends INode {
151
155
  resumeRender: () => void;
152
156
  setCursor: (mode?: string) => void;
153
157
  getTheme: () => IFullThemeSpec;
158
+ eventPointTransform: (e: PointerEvent | WheelEvent | TouchEvent) => {
159
+ x: number;
160
+ y: number;
161
+ };
154
162
  }
155
163
  export declare function combineStage(srages: IStage[], params: {
156
164
  canvas: string | HTMLCanvasElement;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/stage.ts"],"names":[],"mappings":"","file":"stage.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { ILayer, LayerMode } from './layer';\nimport type { IColor } from './color';\nimport type { IAABBBounds, IBounds, IBoundsLike, IMatrix } from '@visactor/vutils';\nimport type { ICamera } from './camera';\nimport type { vec3 } from './matrix';\nimport type { IDirectionLight } from './light';\nimport type { ISyncHook } from './sync-hook';\nimport type { IDrawContext, IRenderService } from './render';\nimport type { ITicker, ITimeline } from './animate';\nimport type { IPickerService, PickResult } from './picker';\nimport type { IPlugin, IPluginService } from './plugin';\nimport type { IWindow } from './window';\nimport type { ILayerService } from './core';\nimport type { IFullThemeSpec } from './graphic/theme';\n\nexport type IExportType = 'canvas' | 'imageData';\n\nexport interface IStageParams {\n // x: number;\n // y: number;\n // // 视口的宽高\n // viewWidth: number;\n // viewHeight: number;\n\n // 视口的宽高\n viewBox: IBoundsLike;\n // 总的宽高\n width: number;\n height: number;\n dpr: number;\n // stage的背景\n background: string | IColor;\n // 外部的canvas\n canvas: string | HTMLCanvasElement;\n // canvas的container容器,如果不传入canvas,那就会在容器中创建canvas\n container: string | HTMLElement;\n // 是否是受控制的canvas,如果不是的话,不会进行resize等操作,也不会修改canvas的样式\n canvasControled: boolean;\n title: string;\n // 是否开启自动渲染\n autoRender: boolean;\n // 是否开启布局支持\n enableLayout: boolean;\n // 是否关闭脏矩形检测\n disableDirtyBounds: boolean;\n // 是否支持interactiveLayer,默认为true\n interactiveLayer: boolean;\n // 是否支持HTML属性\n enableHtmlAttribute: string | boolean | HTMLElement;\n // 是否支持react-dom(传入ReactDOM)\n ReactDOM: any;\n // 是否支持滚动条\n enableScroll: boolean;\n poptip: boolean;\n // 绘制之前的钩子函数\n beforeRender: (stage: IStage) => void;\n // 绘制之后的钩子函数\n afterRender: (stage: IStage) => void;\n renderStyle?: string;\n ticker?: ITicker;\n pluginList?: string[];\n // 优化配置\n optimize?: IOptimizeType;\n /**\n * 事件系统相关配置\n */\n event?: EventConfig;\n\n /**\n * @since 0.17.15\n * 是否支持touch事件,不支持就不监听touch事件\n */\n supportsTouchEvents?: boolean;\n\n /**\n * @since 0.17.15\n * 是否支持pointer事件,不支持就监听mouse事件\n */\n supportsPointerEvents?: boolean;\n}\n\nexport type EventConfig = {\n /** 是否自动阻止事件 */\n autoPreventDefault?: boolean;\n /**\n * 多次点击之间的最大时间,默认为 200 ms\n * @default 200\n */\n clickInterval?: number;\n [key: string]: any;\n};\n\nexport type IOptimizeType = {\n // 视口不在可视区,跳过渲染,默认为true\n skipRenderWithOutRange?: boolean;\n // 跳过图元在区间外的判断\n // 不存在dirtyBounds的时候,根据该配置判断是否关闭图元的超出边界判定\n // 如果有dirtyBounds那么该配置不生效\n disableCheckGraphicWidthOutRange?: boolean;\n};\n\nexport interface IOption3D {\n enableView3dTransform?: boolean; // 是否开启view3d自动旋转\n alpha?: number; // x轴的转角\n beta?: number; // y轴的转角\n gama?: number; // z轴的转角\n center?: { x?: number; y?: number; z?: number; dx?: number; dy?: number; dz?: number }; // 中心位置\n fieldRatio?: number; // 透视的视域缩放比例\n fieldDepth?: number;\n light?: {\n dir?: vec3;\n color?: string;\n ambient?: number;\n };\n // 配置相机后,alpha、beta、gamma配置会失效\n camera?: any; // 相机配置\n}\n\n// TODO 命名方式\nexport interface IStage extends INode {\n stage?: IStage;\n parent: IStage | null;\n // rootNode: IStage;\n x: number;\n y: number;\n\n params: Partial<IStageParams>;\n\n window: IWindow;\n\n width: number;\n height: number;\n viewWidth: number;\n viewHeight: number;\n defaultLayer: ILayer;\n dirtyBounds: IBounds | null;\n\n autoRender: boolean;\n renderCount: number;\n\n hooks: {\n beforeRender: ISyncHook<[IStage]>;\n afterRender: ISyncHook<[IStage]>;\n };\n\n option3d?: IOption3D;\n\n set3dOptions: (options: IOption3D) => void;\n light?: IDirectionLight;\n camera?: ICamera;\n\n dpr: number;\n\n viewBox: IBoundsLike;\n background: string | IColor;\n ticker: ITicker;\n increaseAutoRender: boolean;\n readonly renderService: IRenderService;\n pickerService?: IPickerService;\n readonly pluginService: IPluginService;\n readonly layerService: ILayerService;\n // 如果传入CanvasId,如果存在相同Id,说明这两个图层使用相同的Canvas绘制\n // 但需要注意的是依然是两个图层(用于解决Table嵌入ChartSpace不影响Table的绘制)\n createLayer: (canvasId?: string, layerMode?: LayerMode) => ILayer;\n getLayer: (name: string) => ILayer;\n sortLayer: (cb: (layer1: ILayer, layer2: ILayer) => number) => void;\n removeLayer: (layerId: number) => ILayer | false;\n\n getTimeline: () => ITimeline;\n\n render: (layers?: ILayer[], params?: Partial<IDrawContext>) => void;\n /**\n * 下一帧渲染\n * @param layers 渲染的图层\n * @param force 是否强行下一帧渲染,不采取优化方案\n * @returns\n */\n renderNextFrame: (layers?: ILayer[], force?: boolean) => void;\n tryInitInteractiveLayer: () => void;\n\n // 画布操作\n resize: (w: number, h: number, rerender?: boolean) => void;\n resizeWindow: (w: number, h: number, rerender?: boolean) => void;\n resizeView: (w: number, h: number, rerender?: boolean) => void;\n setViewBox:\n | ((viewBox: IBoundsLike, rerender: boolean) => void)\n | ((x: number, y: number, w: number, h: number, rerender: boolean) => void)\n | ((x: number | IBoundsLike, y: number | boolean, w?: number, h?: number, rerender?: boolean) => void);\n setDpr: (dpr: number, rerender?: boolean) => void;\n setOrigin: (x: number, y: number) => void;\n export: (type: IExportType) => HTMLCanvasElement | ImageData;\n pick: (x: number, y: number) => PickResult | false;\n\n // 动画相关\n startAnimate: (t: number) => void;\n setToFrame: (t: number) => void;\n dirty: (b: IBounds, matrix?: IMatrix) => void;\n // 考虑操作回放\n\n renderTo: (window: IWindow, params: { x: number; y: number; width: number; height: number }) => void;\n\n renderToNewWindow: (fullImage?: boolean) => IWindow;\n\n toCanvas: (fullImage?: boolean, viewBox?: IAABBBounds) => HTMLCanvasElement | null;\n\n setBeforeRender: (cb: (stage: IStage) => void) => void;\n\n setAfterRender: (cb: (stage: IStage) => void) => void;\n\n afterNextRender: (cb: (stage: IStage) => void) => void;\n enableAutoRender: () => void;\n disableAutoRender: () => void;\n enableIncrementalAutoRender: () => void;\n disableIncrementalAutoRender: () => void;\n enableDirtyBounds: () => void;\n disableDirtyBounds: () => void;\n enableView3dTransform: () => void;\n disableView3dTranform: () => void;\n getPluginsByName: (name: string) => IPlugin[];\n clearViewBox: (color?: string) => void;\n release: () => void;\n setStage: (stage?: IStage) => void;\n\n pauseRender: () => void;\n resumeRender: () => void;\n\n setCursor: (mode?: string) => void;\n\n getTheme: () => IFullThemeSpec;\n}\n\nexport declare function combineStage(srages: IStage[], params: { canvas: string | HTMLCanvasElement }): IStage;\n"]}
1
+ {"version":3,"sources":["../src/interface/stage.ts"],"names":[],"mappings":"","file":"stage.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { ILayer, LayerMode } from './layer';\nimport type { IColor } from './color';\nimport type { IAABBBounds, IBounds, IBoundsLike, IMatrix } from '@visactor/vutils';\nimport type { ICamera } from './camera';\nimport type { vec3 } from './matrix';\nimport type { IDirectionLight } from './light';\nimport type { ISyncHook } from './sync-hook';\nimport type { IDrawContext, IRenderService } from './render';\nimport type { ITicker, ITimeline } from './animate';\nimport type { IPickerService, PickResult } from './picker';\nimport type { IPlugin, IPluginService } from './plugin';\nimport type { IWindow } from './window';\nimport type { ILayerService } from './core';\nimport type { IFullThemeSpec } from './graphic/theme';\n\nexport type IExportType = 'canvas' | 'imageData';\n\nexport type IStageCreateContext = {\n appName?: 'vchart' | 'vgrammar' | 'vtable' | string;\n};\nexport interface IStageParams {\n // x: number;\n // y: number;\n // // 视口的宽高\n // viewWidth: number;\n // viewHeight: number;\n\n // 视口的宽高\n viewBox: IBoundsLike;\n // 总的宽高\n width: number;\n height: number;\n dpr: number;\n // stage的背景\n background: string | IColor;\n // 外部的canvas\n canvas: string | HTMLCanvasElement;\n // canvas的container容器,如果不传入canvas,那就会在容器中创建canvas\n container: string | HTMLElement;\n // 是否是受控制的canvas,如果不是的话,不会进行resize等操作,也不会修改canvas的样式\n canvasControled: boolean;\n title: string;\n // 是否开启自动渲染\n autoRender: boolean;\n // 是否开启布局支持\n enableLayout: boolean;\n // 是否关闭脏矩形检测\n disableDirtyBounds: boolean;\n // 是否支持interactiveLayer,默认为true\n interactiveLayer: boolean;\n // 是否支持HTML属性\n enableHtmlAttribute: string | boolean | HTMLElement;\n // 是否支持react-dom(传入ReactDOM)\n ReactDOM: any;\n // 是否支持滚动条\n enableScroll: boolean;\n poptip: boolean;\n // 绘制之前的钩子函数\n beforeRender: (stage: IStage) => void;\n // 绘制之后的钩子函数\n afterRender: (stage: IStage) => void;\n renderStyle?: string;\n ticker?: ITicker;\n pluginList?: string[];\n // 优化配置\n optimize?: IOptimizeType;\n /**\n * 事件系统相关配置\n */\n event?: EventConfig;\n\n /**\n * @since 0.17.15\n * 是否支持touch事件,不支持就不监听touch事件\n */\n supportsTouchEvents?: boolean;\n\n /**\n * @since 0.17.15\n * 是否支持pointer事件,不支持就监听mouse事件\n */\n supportsPointerEvents?: boolean;\n\n context?: IStageCreateContext;\n}\n\nexport type EventConfig = {\n /** 是否自动阻止事件 */\n autoPreventDefault?: boolean;\n /**\n * 多次点击之间的最大时间,默认为 200 ms\n * @default 200\n */\n clickInterval?: number;\n [key: string]: any;\n};\n\nexport type IOptimizeType = {\n // 视口不在可视区,跳过渲染,默认为true\n skipRenderWithOutRange?: boolean;\n // 跳过图元在区间外的判断\n // 不存在dirtyBounds的时候,根据该配置判断是否关闭图元的超出边界判定\n // 如果有dirtyBounds那么该配置不生效\n disableCheckGraphicWidthOutRange?: boolean;\n};\n\nexport interface IOption3D {\n enableView3dTransform?: boolean; // 是否开启view3d自动旋转\n alpha?: number; // x轴的转角\n beta?: number; // y轴的转角\n gama?: number; // z轴的转角\n center?: { x?: number; y?: number; z?: number; dx?: number; dy?: number; dz?: number }; // 中心位置\n fieldRatio?: number; // 透视的视域缩放比例\n fieldDepth?: number;\n light?: {\n dir?: vec3;\n color?: string;\n ambient?: number;\n };\n // 配置相机后,alpha、beta、gamma配置会失效\n camera?: any; // 相机配置\n}\n\n// TODO 命名方式\nexport interface IStage extends INode {\n stage?: IStage;\n parent: IStage | null;\n // rootNode: IStage;\n x: number;\n y: number;\n\n params: Partial<IStageParams>;\n\n window: IWindow;\n\n width: number;\n height: number;\n viewWidth: number;\n viewHeight: number;\n defaultLayer: ILayer;\n dirtyBounds: IBounds | null;\n\n autoRender: boolean;\n renderCount: number;\n\n hooks: {\n beforeRender: ISyncHook<[IStage]>;\n afterRender: ISyncHook<[IStage]>;\n };\n\n option3d?: IOption3D;\n\n set3dOptions: (options: IOption3D) => void;\n light?: IDirectionLight;\n camera?: ICamera;\n\n dpr: number;\n\n viewBox: IBoundsLike;\n background: string | IColor;\n ticker: ITicker;\n increaseAutoRender: boolean;\n readonly renderService: IRenderService;\n pickerService?: IPickerService;\n readonly pluginService: IPluginService;\n readonly layerService: ILayerService;\n // 如果传入CanvasId,如果存在相同Id,说明这两个图层使用相同的Canvas绘制\n // 但需要注意的是依然是两个图层(用于解决Table嵌入ChartSpace不影响Table的绘制)\n createLayer: (canvasId?: string, layerMode?: LayerMode) => ILayer;\n getLayer: (name: string) => ILayer;\n sortLayer: (cb: (layer1: ILayer, layer2: ILayer) => number) => void;\n removeLayer: (layerId: number) => ILayer | false;\n\n getTimeline: () => ITimeline;\n\n render: (layers?: ILayer[], params?: Partial<IDrawContext>) => void;\n /**\n * 下一帧渲染\n * @param layers 渲染的图层\n * @param force 是否强行下一帧渲染,不采取优化方案\n * @returns\n */\n renderNextFrame: (layers?: ILayer[], force?: boolean) => void;\n tryInitInteractiveLayer: () => void;\n\n // 画布操作\n resize: (w: number, h: number, rerender?: boolean) => void;\n resizeWindow: (w: number, h: number, rerender?: boolean) => void;\n resizeView: (w: number, h: number, rerender?: boolean) => void;\n setViewBox:\n | ((viewBox: IBoundsLike, rerender: boolean) => void)\n | ((x: number, y: number, w: number, h: number, rerender: boolean) => void)\n | ((x: number | IBoundsLike, y: number | boolean, w?: number, h?: number, rerender?: boolean) => void);\n setDpr: (dpr: number, rerender?: boolean) => void;\n setOrigin: (x: number, y: number) => void;\n export: (type: IExportType) => HTMLCanvasElement | ImageData;\n pick: (x: number, y: number) => PickResult | false;\n\n // 动画相关\n startAnimate: (t: number) => void;\n setToFrame: (t: number) => void;\n dirty: (b: IBounds, matrix?: IMatrix) => void;\n // 考虑操作回放\n\n renderTo: (window: IWindow, params: { x: number; y: number; width: number; height: number }) => void;\n\n renderToNewWindow: (fullImage?: boolean) => IWindow;\n\n toCanvas: (fullImage?: boolean, viewBox?: IAABBBounds) => HTMLCanvasElement | null;\n\n setBeforeRender: (cb: (stage: IStage) => void) => void;\n\n setAfterRender: (cb: (stage: IStage) => void) => void;\n\n afterNextRender: (cb: (stage: IStage) => void) => void;\n enableAutoRender: () => void;\n disableAutoRender: () => void;\n enableIncrementalAutoRender: () => void;\n disableIncrementalAutoRender: () => void;\n enableDirtyBounds: () => void;\n disableDirtyBounds: () => void;\n enableView3dTransform: () => void;\n disableView3dTranform: () => void;\n getPluginsByName: (name: string) => IPlugin[];\n clearViewBox: (color?: string) => void;\n release: () => void;\n setStage: (stage?: IStage) => void;\n\n pauseRender: () => void;\n resumeRender: () => void;\n\n setCursor: (mode?: string) => void;\n\n getTheme: () => IFullThemeSpec;\n eventPointTransform: (e: PointerEvent | WheelEvent | TouchEvent) => { x: number; y: number };\n}\n\nexport declare function combineStage(srages: IStage[], params: { canvas: string | HTMLCanvasElement }): IStage;\n"]}
@@ -39,7 +39,9 @@ export class FlexLayoutPlugin {
39
39
  })), !isFinite(boundsLegal)) return;
40
40
  width = childrenWidth, height = childrenHeight;
41
41
  }
42
- p.attribute.width = width, p.attribute.height = height, this.tempBounds.copy(p._AABBBounds);
42
+ null == p.attribute.width ? p.attribute.width = width : width = p.attribute.width,
43
+ null == p.attribute.height ? p.attribute.height = height : height = p.attribute.height,
44
+ this.tempBounds.copy(p._AABBBounds);
43
45
  const result = {
44
46
  main: {
45
47
  len: width,
@@ -74,7 +76,7 @@ export class FlexLayoutPlugin {
74
76
  }), tempMainL = 0, tempCrossL = 0) : (mainList.push({
75
77
  idx: i - 1,
76
78
  mainLen: tempMainL,
77
- crossLen: crossLen
79
+ crossLen: tempCrossL
78
80
  }), tempMainL = mainLen, tempCrossL = crossLen) : (tempMainL += mainLen, tempCrossL = Math.max(tempCrossL, crossLen));
79
81
  })), mainList.push({
80
82
  idx: mianLenArray.length - 1,
@@ -171,7 +173,7 @@ export class FlexLayoutPlugin {
171
173
  }
172
174
  } else if ("flex-end" === justifyContent) {
173
175
  let pos = main.len;
174
- for (let i = lastIdx; i <= currSeg.idx; i++) {
176
+ for (let i = currSeg.idx; i >= lastIdx; i--) {
175
177
  pos -= mianLenArray[i].mainLen;
176
178
  const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
177
179
  !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`]));