@visactor/vrender-core 0.17.19-alpha.1 → 0.17.20-alpha.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 (83) hide show
  1. package/cjs/core/stage.d.ts +2 -1
  2. package/cjs/core/stage.js +8 -4
  3. package/cjs/core/stage.js.map +1 -1
  4. package/cjs/graphic/graphic.js +3 -3
  5. package/cjs/graphic/graphic.js.map +1 -1
  6. package/cjs/graphic/node-tree.js +1 -4
  7. package/cjs/graphic/node-tree.js.map +1 -1
  8. package/cjs/graphic/richtext/frame.d.ts +2 -2
  9. package/cjs/graphic/richtext/frame.js +1 -12
  10. package/cjs/graphic/richtext/frame.js.map +1 -1
  11. package/cjs/graphic/richtext/line.js +1 -12
  12. package/cjs/graphic/richtext/line.js.map +1 -1
  13. package/cjs/graphic/richtext/paragraph.js +2 -2
  14. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  15. package/cjs/interface/graphic/richText.d.ts +1 -1
  16. package/cjs/interface/graphic/richText.js.map +1 -1
  17. package/cjs/interface/graphic.d.ts +2 -2
  18. package/cjs/interface/graphic.js.map +1 -1
  19. package/cjs/interface/picker.d.ts +1 -0
  20. package/cjs/interface/picker.js.map +1 -1
  21. package/cjs/interface/render.d.ts +1 -0
  22. package/cjs/interface/render.js.map +1 -1
  23. package/cjs/interface/stage.d.ts +3 -1
  24. package/cjs/interface/stage.js.map +1 -1
  25. package/cjs/picker/picker-service.js +8 -3
  26. package/cjs/picker/picker-service.js.map +1 -1
  27. package/cjs/plugins/builtin-plugin/flex-layout-plugin.d.ts +14 -3
  28. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +126 -65
  29. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
  30. package/cjs/render/contributions/render/draw-contribution.js +13 -6
  31. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  32. package/cjs/render/contributions/render/image-render.js +2 -4
  33. package/cjs/render/contributions/render/image-render.js.map +1 -1
  34. package/cjs/render/contributions/render/incremental-draw-contribution.js +18 -10
  35. package/cjs/render/contributions/render/incremental-draw-contribution.js.map +1 -1
  36. package/cjs/render/contributions/render/index.d.ts +0 -1
  37. package/cjs/render/contributions/render/index.js +1 -2
  38. package/cjs/render/contributions/render/index.js.map +1 -1
  39. package/cjs/resource-loader/loader.d.ts +0 -5
  40. package/cjs/resource-loader/loader.js +15 -56
  41. package/cjs/resource-loader/loader.js.map +1 -1
  42. package/es/core/stage.d.ts +2 -1
  43. package/es/core/stage.js +8 -4
  44. package/es/core/stage.js.map +1 -1
  45. package/es/graphic/graphic.js +4 -4
  46. package/es/graphic/graphic.js.map +1 -1
  47. package/es/graphic/node-tree.js +1 -4
  48. package/es/graphic/node-tree.js.map +1 -1
  49. package/es/graphic/richtext/frame.d.ts +2 -2
  50. package/es/graphic/richtext/frame.js +1 -12
  51. package/es/graphic/richtext/frame.js.map +1 -1
  52. package/es/graphic/richtext/line.js +1 -12
  53. package/es/graphic/richtext/line.js.map +1 -1
  54. package/es/graphic/richtext/paragraph.js +2 -2
  55. package/es/graphic/richtext/paragraph.js.map +1 -1
  56. package/es/interface/graphic/richText.d.ts +1 -1
  57. package/es/interface/graphic/richText.js.map +1 -1
  58. package/es/interface/graphic.d.ts +2 -2
  59. package/es/interface/graphic.js.map +1 -1
  60. package/es/interface/picker.d.ts +1 -0
  61. package/es/interface/picker.js.map +1 -1
  62. package/es/interface/render.d.ts +1 -0
  63. package/es/interface/render.js.map +1 -1
  64. package/es/interface/stage.d.ts +3 -1
  65. package/es/interface/stage.js.map +1 -1
  66. package/es/picker/picker-service.js +8 -3
  67. package/es/picker/picker-service.js.map +1 -1
  68. package/es/plugins/builtin-plugin/flex-layout-plugin.d.ts +14 -3
  69. package/es/plugins/builtin-plugin/flex-layout-plugin.js +126 -69
  70. package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
  71. package/es/render/contributions/render/draw-contribution.js +13 -6
  72. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  73. package/es/render/contributions/render/image-render.js +2 -6
  74. package/es/render/contributions/render/image-render.js.map +1 -1
  75. package/es/render/contributions/render/incremental-draw-contribution.js +18 -10
  76. package/es/render/contributions/render/incremental-draw-contribution.js.map +1 -1
  77. package/es/render/contributions/render/index.d.ts +0 -1
  78. package/es/render/contributions/render/index.js +0 -2
  79. package/es/render/contributions/render/index.js.map +1 -1
  80. package/es/resource-loader/loader.d.ts +0 -5
  81. package/es/resource-loader/loader.js +14 -56
  82. package/es/resource-loader/loader.js.map +1 -1
  83. package/package.json +1 -1
@@ -9,7 +9,7 @@ import type { ISyncHook } from './sync-hook';
9
9
  import type { IDrawContext, IRenderService } from './render';
10
10
  import type { ITicker, ITimeline } from './animate';
11
11
  import type { IPickerService, PickResult } from './picker';
12
- import type { IPluginService } from './plugin';
12
+ import type { IPlugin, IPluginService } from './plugin';
13
13
  import type { IWindow } from './window';
14
14
  import type { ILayerService } from './core';
15
15
  import type { IFullThemeSpec } from './graphic/theme';
@@ -40,6 +40,7 @@ export interface IStageParams {
40
40
  event?: EventConfig;
41
41
  supportsTouchEvents?: boolean;
42
42
  supportsPointerEvents?: boolean;
43
+ renderKeepMatrix?: boolean;
43
44
  }
44
45
  export type EventConfig = {
45
46
  autoPreventDefault?: boolean;
@@ -142,6 +143,7 @@ export interface IStage extends INode {
142
143
  disableDirtyBounds: () => void;
143
144
  enableView3dTransform: () => void;
144
145
  disableView3dTranform: () => void;
146
+ getPluginsByName: (name: string) => IPlugin[];
145
147
  clearViewBox: (color?: string) => void;
146
148
  release: () => void;
147
149
  setStage: (stage?: IStage) => void;
@@ -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 { 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 // 是否支持滚动条\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 clearViewBox: (color?: string) => void;\n release: () => void;\n setStage: (stage?: IStage) => 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 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 // 是否支持滚动条\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 * Render的时候使用原来的矩阵,不清除\n */\n renderKeepMatrix?: 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 setCursor: (mode?: string) => void;\n\n getTheme: () => IFullThemeSpec;\n}\n\nexport declare function combineStage(srages: IStage[], params: { canvas: string | HTMLCanvasElement }): IStage;\n"]}
@@ -45,13 +45,18 @@ let DefaultPickService = class {
45
45
  if (!params.bounds.contains(point.x, point.y)) return result;
46
46
  offsetX = params.bounds.x1, offsetY = params.bounds.y1;
47
47
  }
48
- this.pickContext && (this.pickContext.inuse = !0), params.pickContext = this.pickContext,
49
- this.pickContext && this.pickContext.clearMatrix(!0, 1);
48
+ if (this.pickContext) if (params.keepMatrix) {
49
+ if (this.pickContext.nativeContext && this.pickContext.nativeContext.getTransform) {
50
+ const t = this.pickContext.nativeContext.getTransform();
51
+ this.pickContext.setTransformFromMatrix(t, !0, 1);
52
+ }
53
+ } else this.pickContext.inuse = !0, this.pickContext.clearMatrix(!0, 1);
54
+ params.pickContext = this.pickContext;
50
55
  const parentMatrix = new Matrix(1, 0, 0, 1, offsetX, offsetY);
51
56
  let group;
52
57
  for (let i = graphics.length - 1; i >= 0 && (result = graphics[i].isContainer ? this.pickGroup(graphics[i], point, parentMatrix, params) : this.pickItem(graphics[i], point, parentMatrix, params),
53
58
  !result.graphic); i--) group || (group = result.group);
54
- if (result.graphic || (result.group = group), this.pickContext && (this.pickContext.inuse = !1),
59
+ if (result.graphic || (result.group = group), this.pickContext && !params.keepMatrix && (this.pickContext.inuse = !1),
55
60
  result.graphic) {
56
61
  let g = result.graphic;
57
62
  for (;g.parent; ) g = g.parent;
@@ -1 +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,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC5C,CAAC,EACD,IAAI,EACJ,CAAC,CAAC,OAAO,CAAC,MAAM,CACjB,CAAC;SACH;QACD,IAAI,OAAO,CAAC,WAAW,KAAK,UAAU,EAAE;YACtC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,UAAU,CAAC;QAEjC,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,WAAW,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE;YAC1E,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;SACtB;QACD,cAAc,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC;IAChB,CAAC;IAUS,YAAY,CAAC,OAAiB;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,IAAI,CAAC;SACb;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AA7NqB,kBAAkB;IADvC,UAAU,EAAE;IAUR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,mBAAmB,CAAC,CAAA;;GAVT,kBAAkB,CA6NvC;SA7NqB,kBAAkB","file":"picker-service.js","sourcesContent":["import type { IMatrix, IPoint, IPointLike } from '@visactor/vutils';\nimport { Matrix, Point } from '@visactor/vutils';\nimport { inject, injectable, named } from '../common/inversify-lite';\nimport { foreach } from '../common/sort';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../common/contribution-provider';\nimport type {\n IContext2d,\n IGraphic,\n IGroup,\n EnvType,\n IGlobal,\n IPickerService,\n IGraphicPicker,\n IPickParams,\n PickResult,\n IPickItemInterceptorContribution,\n IContributionProvider\n} from '../interface';\nimport { DefaultAttribute, getTheme, mat3Tomat4, multiplyMat4Mat4 } from '../graphic';\nimport { mat4Allocate, matrixAllocate } from '../allocator/matrix-allocate';\nimport { PickItemInterceptor } from './pick-interceptor';\nimport { application } from '../application';\n\n@injectable()\nexport abstract class DefaultPickService implements IPickerService {\n type: string = 'default';\n declare pickerMap: Map<number, IGraphicPicker>;\n declare pickContext?: IContext2d;\n declare InterceptorContributions: IPickItemInterceptorContribution[];\n declare global: IGlobal;\n\n constructor(\n // 拦截器\n @inject(ContributionProvider)\n @named(PickItemInterceptor)\n protected readonly pickItemInterceptorContributions: IContributionProvider<IPickItemInterceptorContribution>\n ) {\n this.global = application.global;\n }\n\n protected _init() {\n this.InterceptorContributions = this.pickItemInterceptorContributions\n .getContributions()\n .sort((a, b) => a.order - b.order);\n }\n\n abstract configure(global: IGlobal, env: EnvType): void;\n\n // todo: params支持\n // todo: 性能优化\n pick(graphics: IGraphic[], point: IPoint, params: IPickParams): PickResult {\n let result: PickResult = {\n graphic: null,\n group: null\n };\n params.pickerService = this;\n let offsetX = 0;\n let offsetY = 0;\n if (params && params.bounds) {\n if (!params.bounds.contains(point.x, point.y)) {\n return result;\n }\n offsetX = params.bounds.x1;\n offsetY = params.bounds.y1;\n }\n if (this.pickContext) {\n this.pickContext.inuse = true;\n }\n params.pickContext = this.pickContext;\n this.pickContext && this.pickContext.clearMatrix(true, 1);\n\n const parentMatrix = new Matrix(1, 0, 0, 1, offsetX, offsetY);\n let group: IGroup;\n for (let i = graphics.length - 1; i >= 0; i--) {\n if (graphics[i].isContainer) {\n result = this.pickGroup(graphics[i] as IGroup, point, parentMatrix, params);\n } else {\n result = this.pickItem(graphics[i], point, parentMatrix, params);\n }\n if (result.graphic) {\n break;\n }\n if (!group) {\n group = result.group;\n }\n }\n if (!result.graphic) {\n result.group = group;\n }\n if (this.pickContext) {\n this.pickContext.inuse = false;\n }\n\n // 判断是否有shadow-dom\n if (result.graphic) {\n let g = result.graphic;\n while (g.parent) {\n g = g.parent;\n }\n if (g.shadowHost) {\n result.params = {\n shadowTarget: result.graphic\n };\n result.graphic = g.shadowHost;\n }\n }\n return result;\n }\n\n containsPoint(graphic: IGraphic, point: IPointLike, params: IPickParams): boolean {\n return !!this.pickItem(graphic, point, null, params ?? { pickContext: this.pickContext, pickerService: this })\n ?.graphic;\n }\n\n // TODO: 支持3d模式的拾取和自定义path的拾取\n pickGroup(group: IGroup, point: IPointLike, parentMatrix: IMatrix, params: IPickParams): PickResult {\n let result: PickResult = {\n group: null,\n graphic: null\n };\n if (group.attribute.visibleAll === false) {\n return result;\n }\n const context = params.pickContext;\n const lastMatrix = context.modelMatrix;\n // 如果是3d,那么需要生成modelMatrix\n if (context.camera) {\n const m = group.transMatrix;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n if (lastMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastMatrix, matrix);\n mat4Allocate.free(matrix);\n }\n } else {\n // 转化context的matrix为lastMatrix\n mat3Tomat4(matrix, group.globalTransMatrix);\n context.modelMatrix = matrix;\n }\n }\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.beforePickItem) {\n const result = drawContribution.beforePickItem(group, this, point, params, { parentMatrix });\n if (result) {\n if (context.modelMatrix !== lastMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastMatrix;\n return result;\n }\n }\n }\n }\n // 转换坐标空间\n const transMatrix = group.transMatrix;\n const currentGroupMatrix = matrixAllocate.allocateByObj(parentMatrix);\n const newPoint: IPoint = new Point(point.x, point.y);\n currentGroupMatrix.transformPoint(newPoint, newPoint);\n // todo: 支持带有path的group的选中\n const insideGroup = group.AABBBounds.containsPoint(newPoint);\n // 如果group没有被选中,直接跳过(如果是3d模式,那么继续)\n if (!insideGroup && !group.stage.camera) {\n return result;\n }\n // pickGroup,Group目前只支持拦截模式(用于shadow节点)\n const pickedItem = this.pickItem(group, newPoint.clone(), parentMatrix, params);\n if (pickedItem && pickedItem.graphic) {\n result.graphic = pickedItem.graphic;\n result.params = pickedItem.params;\n }\n const groupPicked = group.attribute.pickable !== false && insideGroup;\n\n currentGroupMatrix.multiply(\n transMatrix.a,\n transMatrix.b,\n transMatrix.c,\n transMatrix.d,\n transMatrix.e,\n transMatrix.f\n );\n if (group.attribute.childrenPickable !== false && !(pickedItem && pickedItem.graphic)) {\n foreach(\n group,\n DefaultAttribute.zIndex,\n (graphic: IGraphic) => {\n if (graphic.isContainer) {\n // 偏移scrollX和scrollY\n const newPoint: IPoint = new Point(point.x, point.y);\n const theme = getTheme(group).group;\n const { scrollX = theme.scrollX, scrollY = theme.scrollY } = group.attribute;\n newPoint.x -= scrollX;\n newPoint.y -= scrollY;\n result = this.pickGroup(graphic as IGroup, newPoint, currentGroupMatrix, params);\n } else {\n const newPoint: IPoint = new Point(point.x, point.y);\n currentGroupMatrix.transformPoint(newPoint, newPoint);\n // 偏移scrollX和scrollY\n const theme = getTheme(group).group;\n const { scrollX = theme.scrollX, scrollY = theme.scrollY } = group.attribute;\n newPoint.x -= scrollX;\n newPoint.y -= scrollY;\n const pickedItem = this.pickItem(graphic, newPoint, parentMatrix, params);\n if (pickedItem && pickedItem.graphic) {\n result.graphic = pickedItem.graphic;\n result.params = pickedItem.params;\n }\n }\n return !!result.graphic || !!result.group;\n },\n true,\n !!context.camera\n );\n }\n if (context.modelMatrix !== lastMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastMatrix;\n\n if (!result.graphic && !result.group && groupPicked && !group.stage.camera) {\n result.group = group;\n }\n matrixAllocate.free(currentGroupMatrix);\n return result;\n }\n\n // todo: switch统一改为数字map\n abstract pickItem(\n graphic: IGraphic,\n point: IPointLike,\n parentMatrix: IMatrix | null,\n params: IPickParams\n ): PickResult | null;\n\n protected selectPicker(graphic: IGraphic): IGraphicPicker | null {\n const picker = this.pickerMap.get(graphic.numberType);\n if (!picker) {\n return null;\n }\n return picker;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/picker/picker-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAcvE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGtC,IAAe,kBAAkB,GAAjC,MAAe,kBAAkB;IAOtC,YAIqB,gCAAyF;QAAzF,qCAAgC,GAAhC,gCAAgC,CAAyD;QAV9G,SAAI,GAAW,SAAS,CAAC;QAYvB,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IACnC,CAAC;IAES,KAAK;QACb,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,gCAAgC;aAClE,gBAAgB,EAAE;aAClB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAMD,IAAI,CAAC,QAAoB,EAAE,KAAa,EAAE,MAAmB;QAC3D,IAAI,MAAM,GAAe;YACvB,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,IAAI;SACZ,CAAC;QACF,MAAM,CAAC,aAAa,GA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,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,mBAAmB,CAAC,CAAA;;GAVT,kBAAkB,CAoOvC;SApOqB,kBAAkB","file":"picker-service.js","sourcesContent":["import type { IMatrix, IPoint, IPointLike } from '@visactor/vutils';\nimport { Matrix, Point } from '@visactor/vutils';\nimport { inject, injectable, named } from '../common/inversify-lite';\nimport { foreach } from '../common/sort';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../common/contribution-provider';\nimport type {\n IContext2d,\n IGraphic,\n IGroup,\n EnvType,\n IGlobal,\n IPickerService,\n IGraphicPicker,\n IPickParams,\n PickResult,\n IPickItemInterceptorContribution,\n IContributionProvider\n} from '../interface';\nimport { DefaultAttribute, getTheme, mat3Tomat4, multiplyMat4Mat4 } from '../graphic';\nimport { mat4Allocate, matrixAllocate } from '../allocator/matrix-allocate';\nimport { PickItemInterceptor } from './pick-interceptor';\nimport { application } from '../application';\n\n@injectable()\nexport abstract class DefaultPickService implements IPickerService {\n type: string = 'default';\n declare pickerMap: Map<number, IGraphicPicker>;\n declare pickContext?: IContext2d;\n declare InterceptorContributions: IPickItemInterceptorContribution[];\n declare global: IGlobal;\n\n constructor(\n // 拦截器\n @inject(ContributionProvider)\n @named(PickItemInterceptor)\n protected readonly pickItemInterceptorContributions: IContributionProvider<IPickItemInterceptorContribution>\n ) {\n this.global = application.global;\n }\n\n protected _init() {\n this.InterceptorContributions = this.pickItemInterceptorContributions\n .getContributions()\n .sort((a, b) => a.order - b.order);\n }\n\n abstract configure(global: IGlobal, env: EnvType): void;\n\n // todo: params支持\n // todo: 性能优化\n pick(graphics: IGraphic[], point: IPoint, params: IPickParams): PickResult {\n let result: PickResult = {\n graphic: null,\n group: null\n };\n params.pickerService = this;\n let offsetX = 0;\n let offsetY = 0;\n if (params && params.bounds) {\n if (!params.bounds.contains(point.x, point.y)) {\n return result;\n }\n offsetX = params.bounds.x1;\n offsetY = params.bounds.y1;\n }\n if (this.pickContext) {\n if (params.keepMatrix) {\n if (this.pickContext.nativeContext && this.pickContext.nativeContext.getTransform) {\n const t = this.pickContext.nativeContext.getTransform();\n this.pickContext.setTransformFromMatrix(t, true, 1);\n }\n } else {\n this.pickContext.inuse = true;\n this.pickContext.clearMatrix(true, 1);\n }\n }\n params.pickContext = this.pickContext;\n\n const parentMatrix = new Matrix(1, 0, 0, 1, offsetX, offsetY);\n let group: IGroup;\n for (let i = graphics.length - 1; i >= 0; i--) {\n if (graphics[i].isContainer) {\n result = this.pickGroup(graphics[i] as IGroup, point, parentMatrix, params);\n } else {\n result = this.pickItem(graphics[i], point, parentMatrix, params);\n }\n if (result.graphic) {\n break;\n }\n if (!group) {\n group = result.group;\n }\n }\n if (!result.graphic) {\n result.group = group;\n }\n if (this.pickContext && !params.keepMatrix) {\n this.pickContext.inuse = false;\n }\n\n // 判断是否有shadow-dom\n if (result.graphic) {\n let g = result.graphic;\n while (g.parent) {\n g = g.parent;\n }\n if (g.shadowHost) {\n result.params = {\n shadowTarget: result.graphic\n };\n result.graphic = g.shadowHost;\n }\n }\n return result;\n }\n\n containsPoint(graphic: IGraphic, point: IPointLike, params: IPickParams): boolean {\n return !!this.pickItem(graphic, point, null, params ?? { pickContext: this.pickContext, pickerService: this })\n ?.graphic;\n }\n\n // TODO: 支持3d模式的拾取和自定义path的拾取\n pickGroup(group: IGroup, point: IPointLike, parentMatrix: IMatrix, params: IPickParams): PickResult {\n let result: PickResult = {\n group: null,\n graphic: null\n };\n if (group.attribute.visibleAll === false) {\n return result;\n }\n const context = params.pickContext;\n const lastMatrix = context.modelMatrix;\n // 如果是3d,那么需要生成modelMatrix\n if (context.camera) {\n const m = group.transMatrix;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n if (lastMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastMatrix, matrix);\n mat4Allocate.free(matrix);\n }\n } else {\n // 转化context的matrix为lastMatrix\n mat3Tomat4(matrix, group.globalTransMatrix);\n context.modelMatrix = matrix;\n }\n }\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.beforePickItem) {\n const result = drawContribution.beforePickItem(group, this, point, params, { parentMatrix });\n if (result) {\n if (context.modelMatrix !== lastMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastMatrix;\n return result;\n }\n }\n }\n }\n // 转换坐标空间\n const transMatrix = group.transMatrix;\n const currentGroupMatrix = matrixAllocate.allocateByObj(parentMatrix);\n const newPoint: IPoint = new Point(point.x, point.y);\n currentGroupMatrix.transformPoint(newPoint, newPoint);\n // todo: 支持带有path的group的选中\n const insideGroup = group.AABBBounds.containsPoint(newPoint);\n // 如果group没有被选中,直接跳过(如果是3d模式,那么继续)\n if (!insideGroup && !group.stage.camera) {\n return result;\n }\n // pickGroup,Group目前只支持拦截模式(用于shadow节点)\n const pickedItem = this.pickItem(group, newPoint.clone(), parentMatrix, params);\n if (pickedItem && pickedItem.graphic) {\n result.graphic = pickedItem.graphic;\n result.params = pickedItem.params;\n }\n const groupPicked = group.attribute.pickable !== false && insideGroup;\n\n currentGroupMatrix.multiply(\n transMatrix.a,\n transMatrix.b,\n transMatrix.c,\n transMatrix.d,\n transMatrix.e,\n transMatrix.f\n );\n if (group.attribute.childrenPickable !== false && !(pickedItem && pickedItem.graphic)) {\n foreach(\n group,\n DefaultAttribute.zIndex,\n (graphic: IGraphic) => {\n if (graphic.isContainer) {\n // 偏移scrollX和scrollY\n const newPoint: IPoint = new Point(point.x, point.y);\n const theme = getTheme(group).group;\n const { scrollX = theme.scrollX, scrollY = theme.scrollY } = group.attribute;\n newPoint.x -= scrollX;\n newPoint.y -= scrollY;\n result = this.pickGroup(graphic as IGroup, newPoint, currentGroupMatrix, params);\n } else {\n const newPoint: IPoint = new Point(point.x, point.y);\n currentGroupMatrix.transformPoint(newPoint, newPoint);\n // 偏移scrollX和scrollY\n const theme = getTheme(group).group;\n const { scrollX = theme.scrollX, scrollY = theme.scrollY } = group.attribute;\n newPoint.x -= scrollX;\n newPoint.y -= scrollY;\n const pickedItem = this.pickItem(graphic, newPoint, parentMatrix, params);\n if (pickedItem && pickedItem.graphic) {\n result.graphic = pickedItem.graphic;\n result.params = pickedItem.params;\n }\n }\n return !!result.graphic || !!result.group;\n },\n true,\n !!context.camera\n );\n }\n if (context.modelMatrix !== lastMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastMatrix;\n\n if (!result.graphic && !result.group && groupPicked && !group.stage.camera) {\n result.group = group;\n }\n matrixAllocate.free(currentGroupMatrix);\n return result;\n }\n\n // todo: switch统一改为数字map\n abstract pickItem(\n graphic: IGraphic,\n point: IPointLike,\n parentMatrix: IMatrix | null,\n params: IPickParams\n ): PickResult | null;\n\n protected selectPicker(graphic: IGraphic): IGraphicPicker | null {\n const picker = this.pickerMap.get(graphic.numberType);\n if (!picker) {\n return null;\n }\n return picker;\n }\n}\n"]}
@@ -1,6 +1,11 @@
1
1
  import type { IGraphic, IGroup, IGroupAttribute } from '../../interface';
2
2
  import type { IPlugin, IPluginService } from '../../interface';
3
3
  import { AABBBounds } from '@visactor/vutils';
4
+ type IAnchorPosMap = {
5
+ 'flex-start': number;
6
+ 'flex-end': number;
7
+ center: number;
8
+ };
4
9
  export declare class FlexLayoutPlugin implements IPlugin {
5
10
  name: 'FlexLayoutPlugin';
6
11
  activeEvent: 'onRegister';
@@ -8,8 +13,13 @@ export declare class FlexLayoutPlugin implements IPlugin {
8
13
  id: number;
9
14
  key: string;
10
15
  tempBounds: AABBBounds;
11
- layouting: boolean;
12
- tryLayout(graphic: IGraphic): void;
16
+ pause: boolean;
17
+ skipBoundsTrigger: boolean;
18
+ pauseLayout(p: boolean): void;
19
+ tryLayoutChildren(graphic: IGraphic): void;
20
+ tryLayout(graphic: IGraphic, force?: boolean): void;
21
+ getAABBBounds(graphic: IGraphic): import("@visactor/vutils").IBounds;
22
+ private updateChildPos;
13
23
  layoutMain(p: IGroup, children: IGraphic[], justifyContent: IGroupAttribute['justifyContent'], main: {
14
24
  len: number;
15
25
  field: string;
@@ -24,7 +34,7 @@ export declare class FlexLayoutPlugin implements IPlugin {
24
34
  layoutCross(children: IGraphic[], alignItem: IGroupAttribute['alignItems'], cross: {
25
35
  len: number;
26
36
  field: string;
27
- }, anchorPos: number, lenArray: {
37
+ }, anchorPosMap: IAnchorPosMap, lenArray: {
28
38
  mainLen: number;
29
39
  crossLen: number;
30
40
  }[], currSeg: {
@@ -35,3 +45,4 @@ export declare class FlexLayoutPlugin implements IPlugin {
35
45
  activate(context: IPluginService): void;
36
46
  deactivate(context: IPluginService): void;
37
47
  }
48
+ export {};
@@ -2,11 +2,7 @@ import { getTheme } from "../../graphic";
2
2
 
3
3
  import { Generator } from "../../common/generator";
4
4
 
5
- import { isNumber } from "../../canvas/util";
6
-
7
- import { parsePadding } from "../../common/utils";
8
-
9
- import { AABBBounds, isArray } from "@visactor/vutils";
5
+ import { AABBBounds } from "@visactor/vutils";
10
6
 
11
7
  import { application } from "../../application";
12
8
 
@@ -17,25 +13,33 @@ export class FlexLayoutPlugin {
17
13
  this.name = "FlexLayoutPlugin", this.activeEvent = "onRegister", this.id = Generator.GenAutoIncrementId(),
18
14
  this.key = this.name + this.id, this.tempBounds = new AABBBounds;
19
15
  }
20
- tryLayout(graphic) {
21
- if (this.layouting) return;
22
- this.layouting = !0;
16
+ pauseLayout(p) {
17
+ this.pause = p;
18
+ }
19
+ tryLayoutChildren(graphic) {
20
+ graphic.firstChild && this.tryLayout(graphic.firstChild);
21
+ }
22
+ tryLayout(graphic, force = !0) {
23
+ if (this.pause) return;
23
24
  const p = graphic.parent;
24
- if (!p || !graphic.needUpdateLayout()) return;
25
+ if (!(force || p && graphic.needUpdateLayout())) return;
25
26
  const theme = getTheme(p).group, {display: display = theme.display} = p.attribute;
26
27
  if ("flex" !== display) return;
27
- const {flexDirection: flexDirection = theme.flexDirection, flexWrap: flexWrap = theme.flexWrap, justifyContent: justifyContent = theme.justifyContent, alignItems: alignItems = theme.alignItems, alignContent: alignContent = theme.alignContent, clip: clip = theme.clip} = p.attribute;
28
- let childrenWidth = 0, childrenHeight = 0, boundsLegal = 0;
29
- if (p.forEachChildren((child => {
30
- const bounds = child.AABBBounds;
31
- "column" === flexDirection || "column-reverse" === flexDirection ? (childrenHeight += bounds.height(),
32
- childrenWidth = Math.max(childrenWidth, bounds.width())) : (childrenWidth += bounds.width(),
33
- childrenHeight = Math.max(childrenHeight, bounds.height())), boundsLegal += bounds.x1,
34
- boundsLegal += bounds.y1, boundsLegal += bounds.x2, boundsLegal += bounds.y2;
35
- })), !isFinite(boundsLegal)) return;
36
- const width = p.attribute.width || childrenWidth, height = p.attribute.height || childrenHeight;
37
- p.attribute.width || (p.attribute.width = 0), p.attribute.height || (p.attribute.height = 0),
38
- this.tempBounds.copy(p._AABBBounds);
28
+ const {flexDirection: flexDirection = theme.flexDirection, flexWrap: flexWrap = theme.flexWrap, alignItems: alignItems = theme.alignItems, clip: clip = theme.clip} = p.attribute, {alignContent: alignContent = (null != alignItems ? alignItems : theme.alignContent)} = p.attribute;
29
+ let {width: width, height: height, justifyContent: justifyContent = theme.justifyContent} = p.attribute;
30
+ const children = p.getChildren();
31
+ if (null == width || null == height) {
32
+ let childrenWidth = 0, childrenHeight = 0, boundsLegal = 0;
33
+ if (children.forEach((child => {
34
+ const bounds = this.getAABBBounds(child);
35
+ bounds.empty() || ("column" === flexDirection || "column-reverse" === flexDirection ? (childrenHeight += bounds.height(),
36
+ childrenWidth = Math.max(childrenWidth, bounds.width())) : (childrenWidth += bounds.width(),
37
+ childrenHeight = Math.max(childrenHeight, bounds.height())), boundsLegal += bounds.x1,
38
+ boundsLegal += bounds.y1, boundsLegal += bounds.x2, boundsLegal += bounds.y2);
39
+ })), !isFinite(boundsLegal)) return;
40
+ width = childrenWidth, height = childrenHeight;
41
+ }
42
+ p.attribute.width = width, p.attribute.height = height, this.tempBounds.copy(p._AABBBounds);
39
43
  const result = {
40
44
  main: {
41
45
  len: width,
@@ -44,16 +48,16 @@ export class FlexLayoutPlugin {
44
48
  cross: {
45
49
  len: height,
46
50
  field: "y"
47
- },
48
- dir: 1
51
+ }
49
52
  }, main = result.main, cross = result.cross;
50
- "row-reverse" === flexDirection ? result.dir = -1 : "column" === flexDirection ? (main.len = height,
51
- cross.len = width, main.field = "y", cross.field = "x") : "column-reverse" === flexDirection && (main.len = height,
52
- cross.len = width, main.field = "y", cross.field = "x", result.dir = -1);
53
+ "column" !== flexDirection && "column-reverse" !== flexDirection || (main.len = height,
54
+ cross.len = width, main.field = "y", cross.field = "x"), "row-reverse" !== flexDirection && "column-reverse" !== flexDirection || ("flex-start" === justifyContent ? justifyContent = "flex-end" : "flex-end" === justifyContent ? justifyContent = "flex-start" : children.reverse());
53
55
  let mainLen = 0, crossLen = 0;
54
56
  const mianLenArray = [];
55
- p.forEachChildren((c => {
56
- const b = c.AABBBounds, ml = "x" === main.field ? b.width() : b.height(), cl = "x" === cross.field ? b.width() : b.height();
57
+ children.forEach((c => {
58
+ const b = this.getAABBBounds(c);
59
+ if (b.empty()) return;
60
+ const ml = "x" === main.field ? b.width() : b.height(), cl = "x" === cross.field ? b.width() : b.height();
57
61
  mianLenArray.push({
58
62
  mainLen: ml,
59
63
  crossLen: cl
@@ -82,30 +86,38 @@ export class FlexLayoutPlugin {
82
86
  mainLen: mainLen,
83
87
  crossLen: crossLen
84
88
  });
85
- const children = p.getChildren();
86
89
  let lastIdx = 0;
87
90
  if (mainList.forEach((s => {
88
91
  this.layoutMain(p, children, justifyContent, main, mianLenArray, lastIdx, s), lastIdx = s.idx + 1;
89
- })), crossLen = mainList.reduce(((a, b) => a + b.crossLen), 0), 1 === mainList.length) if ("flex-end" === alignItems) {
90
- const anchorPos = cross.len;
91
- this.layoutCross(children, alignItems, cross, anchorPos, mianLenArray, mainList[0], 0);
92
- } else if ("center" === alignItems) {
93
- const anchorPos = cross.len / 2;
94
- this.layoutCross(children, alignItems, cross, anchorPos, mianLenArray, mainList[0], 0);
95
- } else children.forEach((child => {
96
- child.attribute[cross.field] = getPadding(child, cross.field);
97
- })); else if ("flex-start" === alignContent) {
92
+ })), crossLen = mainList.reduce(((a, b) => a + b.crossLen), 0), 1 === mainList.length) {
93
+ const anchorPosMap = {
94
+ "flex-start": 0,
95
+ "flex-end": cross.len,
96
+ center: cross.len / 2
97
+ };
98
+ this.layoutCross(children, alignItems, cross, anchorPosMap, mianLenArray, mainList[0], 0);
99
+ } else if ("flex-start" === alignContent) {
98
100
  lastIdx = 0;
99
101
  let anchorPos = 0;
100
102
  mainList.forEach(((s, i) => {
101
- this.layoutCross(children, "flex-start", cross, anchorPos, mianLenArray, mainList[i], lastIdx),
103
+ const anchorPosMap = {
104
+ "flex-start": anchorPos,
105
+ "flex-end": anchorPos + s.crossLen,
106
+ center: anchorPos + s.crossLen / 2
107
+ };
108
+ this.layoutCross(children, "flex-start", cross, anchorPosMap, mianLenArray, mainList[i], lastIdx),
102
109
  lastIdx = s.idx + 1, anchorPos += s.crossLen;
103
110
  }));
104
111
  } else if ("center" === alignContent) {
105
112
  lastIdx = 0;
106
113
  let anchorPos = Math.max(0, (cross.len - crossLen) / 2);
107
114
  mainList.forEach(((s, i) => {
108
- this.layoutCross(children, "center", cross, anchorPos + s.crossLen / 2, mianLenArray, mainList[i], lastIdx),
115
+ const anchorPosMap = {
116
+ "flex-start": anchorPos,
117
+ "flex-end": anchorPos + s.crossLen,
118
+ center: anchorPos + s.crossLen / 2
119
+ };
120
+ this.layoutCross(children, "center", cross, anchorPosMap, mianLenArray, mainList[i], lastIdx),
109
121
  lastIdx = s.idx + 1, anchorPos += s.crossLen;
110
122
  }));
111
123
  } else if ("space-around" === alignContent) {
@@ -113,7 +125,12 @@ export class FlexLayoutPlugin {
113
125
  const padding = Math.max(0, (cross.len - crossLen) / mainList.length / 2);
114
126
  let anchorPos = padding;
115
127
  mainList.forEach(((s, i) => {
116
- this.layoutCross(children, "flex-start", cross, anchorPos, mianLenArray, mainList[i], lastIdx),
128
+ const anchorPosMap = {
129
+ "flex-start": anchorPos,
130
+ "flex-end": anchorPos + s.crossLen,
131
+ center: anchorPos + s.crossLen / 2
132
+ };
133
+ this.layoutCross(children, "flex-start", cross, anchorPosMap, mianLenArray, mainList[i], lastIdx),
117
134
  lastIdx = s.idx + 1, anchorPos += s.crossLen + 2 * padding;
118
135
  }));
119
136
  } else if ("space-between" === alignContent) {
@@ -121,73 +138,113 @@ export class FlexLayoutPlugin {
121
138
  const padding = Math.max(0, (cross.len - crossLen) / (2 * mainList.length - 2));
122
139
  let anchorPos = 0;
123
140
  mainList.forEach(((s, i) => {
124
- this.layoutCross(children, "flex-start", cross, anchorPos, mianLenArray, mainList[i], lastIdx),
141
+ const anchorPosMap = {
142
+ "flex-start": anchorPos,
143
+ "flex-end": anchorPos + s.crossLen,
144
+ center: anchorPos + s.crossLen / 2
145
+ };
146
+ this.layoutCross(children, "flex-start", cross, anchorPosMap, mianLenArray, mainList[i], lastIdx),
125
147
  lastIdx = s.idx + 1, anchorPos += s.crossLen + 2 * padding;
126
148
  }));
127
149
  }
128
150
  children.forEach(((child, idx) => {
129
151
  child.addUpdateBoundTag(), child.addUpdatePositionTag(), child.clearUpdateLayoutTag();
130
- })), p.addUpdateLayoutTag(), clip || this.tempBounds.equals(p.AABBBounds) || (this.tryLayout(p),
131
- this.layouting = !1);
152
+ })), p.addUpdateLayoutTag();
153
+ const b = this.getAABBBounds(p);
154
+ clip || this.tempBounds.equals(b) || this.tryLayout(p, !1);
155
+ }
156
+ getAABBBounds(graphic) {
157
+ this.skipBoundsTrigger = !0;
158
+ const b = graphic.AABBBounds;
159
+ return this.skipBoundsTrigger = !1, b;
160
+ }
161
+ updateChildPos(posBaseLeftTop, lastP, lastBP) {
162
+ return posBaseLeftTop + (null != lastP ? lastP : 0) - lastBP;
132
163
  }
133
164
  layoutMain(p, children, justifyContent, main, mianLenArray, lastIdx, currSeg) {
134
165
  if ("flex-start" === justifyContent) {
135
166
  let pos = 0;
136
- for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[main.field] = pos + getPadding(children[i], main.field),
137
- pos += mianLenArray[i].mainLen;
167
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
168
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
169
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
170
+ pos += mianLenArray[i].mainLen;
171
+ }
138
172
  } else if ("flex-end" === justifyContent) {
139
173
  let pos = main.len;
140
- for (let i = lastIdx; i <= currSeg.idx; i++) pos -= mianLenArray[i].mainLen, children[i].attribute[main.field] = pos + getPadding(children[i], main.field);
174
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
175
+ pos -= mianLenArray[i].mainLen;
176
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
177
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`]));
178
+ }
141
179
  } else if ("space-around" === justifyContent) if (currSeg.mainLen >= main.len) {
142
180
  let pos = 0;
143
- for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[main.field] = pos + getPadding(children[i], main.field),
144
- pos += mianLenArray[i].mainLen;
181
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
182
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
183
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
184
+ pos += mianLenArray[i].mainLen;
185
+ }
145
186
  } else {
146
187
  const size = currSeg.idx - lastIdx + 1, padding = (main.len - currSeg.mainLen) / size / 2;
147
188
  let pos = padding;
148
- for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[main.field] = pos + getPadding(children[i], main.field),
149
- pos += mianLenArray[i].mainLen + 2 * padding;
189
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
190
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
191
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
192
+ pos += mianLenArray[i].mainLen + 2 * padding;
193
+ }
150
194
  } else if ("space-between" === justifyContent) if (currSeg.mainLen >= main.len) {
151
195
  let pos = 0;
152
- for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[main.field] = pos + getPadding(children[i], main.field),
153
- pos += mianLenArray[i].mainLen;
196
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
197
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
198
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
199
+ pos += mianLenArray[i].mainLen;
200
+ }
154
201
  } else {
155
202
  const size = currSeg.idx - lastIdx + 1, padding = (main.len - currSeg.mainLen) / (2 * size - 2);
156
203
  let pos = 0;
157
- for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[main.field] = pos + getPadding(children[i], main.field),
158
- pos += mianLenArray[i].mainLen + 2 * padding;
204
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
205
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
206
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
207
+ pos += mianLenArray[i].mainLen + 2 * padding;
208
+ }
159
209
  } else if ("center" === justifyContent) {
160
210
  let pos = (main.len - currSeg.mainLen) / 2;
161
- for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[main.field] = pos + getPadding(children[i], main.field),
162
- pos += mianLenArray[i].mainLen;
211
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
212
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
213
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
214
+ pos += mianLenArray[i].mainLen;
215
+ }
163
216
  }
164
217
  }
165
- layoutCross(children, alignItem, cross, anchorPos, lenArray, currSeg, lastIdx) {
166
- if ("flex-end" === alignItem) for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[cross.field] = anchorPos - lenArray[i].crossLen + getPadding(children[i], cross.field); else if ("center" === alignItem) for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[cross.field] = anchorPos - lenArray[i].crossLen / 2 + getPadding(children[i], cross.field); else for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[cross.field] = anchorPos + getPadding(children[i], cross.field);
218
+ layoutCross(children, alignItem, cross, anchorPosMap, lenArray, currSeg, lastIdx) {
219
+ var _a;
220
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
221
+ const child = children[i];
222
+ let {alignSelf: alignSelf} = child.attribute;
223
+ alignSelf && "auto" !== alignSelf || (alignSelf = alignItem);
224
+ const b = this.getAABBBounds(child), anchorPos = null !== (_a = anchorPosMap[alignSelf]) && void 0 !== _a ? _a : anchorPosMap["flex-start"];
225
+ "flex-end" === alignSelf ? !b.empty() && (child.attribute[cross.field] = this.updateChildPos(anchorPos - lenArray[i].crossLen + getPadding(child, cross.field), child.attribute[cross.field], b[`${cross.field}1`])) : "center" === alignSelf ? !b.empty() && (child.attribute[cross.field] = this.updateChildPos(anchorPos - lenArray[i].crossLen / 2 + getPadding(child, cross.field), child.attribute[cross.field], b[`${cross.field}1`])) : !b.empty() && (child.attribute[cross.field] = this.updateChildPos(anchorPos + getPadding(child, cross.field), child.attribute[cross.field], b[`${cross.field}1`]));
226
+ }
167
227
  }
168
228
  activate(context) {
169
229
  this.pluginService = context, application.graphicService.hooks.onAttributeUpdate.tap(this.key, (graphic => {
170
- graphic.glyphHost && (graphic = graphic.glyphHost), this.tryLayout(graphic), this.layouting = !1;
230
+ graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage && graphic.stage === this.pluginService.stage && this.tryLayout(graphic, !1);
171
231
  })), application.graphicService.hooks.beforeUpdateAABBBounds.tap(this.key, ((graphic, stage, willUpdate, bounds) => {
172
- graphic.glyphHost && (graphic = graphic.glyphHost), stage && stage === this.pluginService.stage && graphic.isContainer && _tempBounds.copy(bounds);
232
+ graphic.glyphHost && (graphic = graphic.glyphHost), stage && stage === this.pluginService.stage && graphic.isContainer && !this.skipBoundsTrigger && _tempBounds.copy(bounds);
173
233
  })), application.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, ((graphic, stage, bounds, params, selfChange) => {
174
- stage && stage === this.pluginService.stage && graphic.isContainer && (_tempBounds.equals(bounds) || (this.tryLayout(graphic),
175
- this.layouting = !1));
234
+ stage && stage === this.pluginService.stage && graphic.isContainer && !this.skipBoundsTrigger && (_tempBounds.equals(bounds) || this.tryLayout(graphic, !1));
176
235
  })), application.graphicService.hooks.onSetStage.tap(this.key, (graphic => {
177
- graphic.glyphHost && (graphic = graphic.glyphHost), this.tryLayout(graphic), this.layouting = !1;
236
+ graphic.glyphHost && (graphic = graphic.glyphHost), this.tryLayout(graphic, !1);
178
237
  }));
179
238
  }
180
239
  deactivate(context) {
181
240
  application.graphicService.hooks.onAttributeUpdate.taps = application.graphicService.hooks.onAttributeUpdate.taps.filter((item => item.name !== this.key)),
241
+ application.graphicService.hooks.beforeUpdateAABBBounds.taps = application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
242
+ application.graphicService.hooks.afterUpdateAABBBounds.taps = application.graphicService.hooks.afterUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
182
243
  application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter((item => item.name !== this.key));
183
244
  }
184
245
  }
185
246
 
186
247
  function getPadding(graphic, field) {
187
- if (!graphic.attribute.boundsPadding) return 0;
188
- if (isNumber(graphic.attribute.boundsPadding)) return graphic.attribute.boundsPadding;
189
- if (isArray(graphic.attribute.boundsPadding) && 1 === graphic.attribute.boundsPadding.length) return graphic.attribute.boundsPadding[0];
190
- const paddingArray = parsePadding(graphic.attribute.boundsPadding);
191
- return "x" === field ? paddingArray[3] : "y" === field ? paddingArray[0] : 0;
248
+ return 0;
192
249
  }
193
250
  //# sourceMappingURL=flex-layout-plugin.js.map