@visactor/vrender-core 0.22.15-alpha.1 → 0.22.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/animate/Ticker/default-ticker.d.ts +40 -0
- package/cjs/animate/Ticker/default-ticker.js +140 -0
- package/cjs/animate/Ticker/default-ticker.js.map +1 -0
- package/cjs/animate/Ticker/index.d.ts +5 -0
- package/cjs/{interface/animation → animate/Ticker}/index.js +3 -3
- package/cjs/animate/Ticker/index.js.map +1 -0
- package/cjs/animate/Ticker/manual-ticker-handler.d.ts +15 -0
- package/cjs/animate/Ticker/manual-ticker-handler.js +36 -0
- package/cjs/animate/Ticker/manual-ticker-handler.js.map +1 -0
- package/cjs/animate/Ticker/manual-ticker.d.ts +19 -0
- package/cjs/animate/Ticker/manual-ticker.js +37 -0
- package/cjs/animate/Ticker/manual-ticker.js.map +1 -0
- package/cjs/animate/Ticker/raf-tick-handler.d.ts +9 -0
- package/cjs/animate/Ticker/raf-tick-handler.js +30 -0
- package/cjs/animate/Ticker/raf-tick-handler.js.map +1 -0
- package/cjs/animate/Ticker/timeout-tick-handler.d.ts +9 -0
- package/cjs/animate/Ticker/timeout-tick-handler.js +28 -0
- package/cjs/animate/Ticker/timeout-tick-handler.js.map +1 -0
- package/cjs/animate/Ticker/type.d.ts +6 -0
- package/cjs/{interface/animation/ticker.js → animate/Ticker/type.js} +1 -1
- package/cjs/animate/Ticker/type.js.map +1 -0
- package/cjs/animate/animate.d.ts +147 -0
- package/cjs/animate/animate.js +403 -0
- package/cjs/animate/animate.js.map +1 -0
- package/cjs/animate/config.d.ts +2 -1
- package/cjs/animate/config.js +5 -1
- package/cjs/animate/config.js.map +1 -1
- package/cjs/animate/custom-animate.d.ts +236 -0
- package/cjs/animate/custom-animate.js +726 -0
- package/cjs/animate/custom-animate.js.map +1 -0
- package/cjs/animate/default-ticker.d.ts +2 -0
- package/cjs/animate/default-ticker.js +14 -0
- package/cjs/animate/default-ticker.js.map +1 -0
- package/cjs/animate/easing-func.d.ts +1 -0
- package/cjs/animate/easing-func.js +16 -0
- package/cjs/animate/easing-func.js.map +1 -0
- package/cjs/animate/easing.d.ts +49 -0
- package/cjs/animate/easing.js +141 -0
- package/cjs/animate/easing.js.map +1 -0
- package/cjs/animate/group-fade.d.ts +16 -0
- package/cjs/animate/group-fade.js +66 -0
- package/cjs/animate/group-fade.js.map +1 -0
- package/cjs/animate/index.d.ts +8 -0
- package/cjs/animate/index.js +24 -0
- package/cjs/animate/index.js.map +1 -0
- package/cjs/animate/morphing.d.ts +52 -0
- package/cjs/animate/morphing.js +292 -0
- package/cjs/animate/morphing.js.map +1 -0
- package/cjs/animate/timeline.d.ts +17 -0
- package/cjs/animate/timeline.js +46 -0
- package/cjs/animate/timeline.js.map +1 -0
- package/cjs/application.d.ts +1 -2
- package/cjs/application.js.map +1 -1
- package/cjs/canvas/constants.js +2 -1
- package/cjs/canvas/empty-context.d.ts +0 -1
- package/cjs/canvas/empty-context.js +0 -4
- package/cjs/canvas/empty-context.js.map +1 -1
- package/cjs/color-string/interpolate.d.ts +0 -1
- package/cjs/color-string/interpolate.js +4 -12
- package/cjs/color-string/interpolate.js.map +1 -1
- package/cjs/color-string/store.js +1 -2
- package/cjs/common/custom-path2d.js +2 -2
- package/cjs/common/custom-path2d.js.map +1 -1
- package/cjs/common/enums.d.ts +16 -0
- package/cjs/common/enums.js +11 -2
- package/cjs/common/enums.js.map +1 -1
- package/cjs/common/morphing-utils.js +124 -32
- package/cjs/common/morphing-utils.js.map +1 -1
- package/cjs/common/polygon.js +2 -5
- package/cjs/common/polygon.js.map +1 -1
- package/cjs/common/segment/curve/cubic-bezier.d.ts +2 -1
- package/cjs/common/segment/curve/cubic-bezier.js +8 -3
- package/cjs/common/segment/curve/cubic-bezier.js.map +1 -1
- package/cjs/common/segment/curve/quadratic-bezier.d.ts +0 -1
- package/cjs/common/segment/curve/quadratic-bezier.js +3 -10
- package/cjs/common/segment/curve/quadratic-bezier.js.map +1 -1
- package/cjs/common/segment/index.d.ts +0 -1
- package/cjs/common/segment/index.js +1 -1
- package/cjs/common/segment/index.js.map +1 -1
- package/cjs/common/shape/arc.d.ts +1 -1
- package/cjs/common/shape/arc.js +3 -7
- package/cjs/common/shape/arc.js.map +1 -1
- package/cjs/common/simplify.js +2 -1
- package/cjs/common/sort.js +1 -1
- package/cjs/common/split-path.js +2 -2
- package/cjs/common/split-path.js.map +1 -1
- package/cjs/common/store.js +1 -1
- package/cjs/common/text.js +1 -1
- package/cjs/common/utils.d.ts +2 -0
- package/cjs/common/utils.js +9 -5
- package/cjs/common/utils.js.map +1 -1
- package/cjs/core/application.js +1 -1
- package/cjs/core/camera.js +1 -1
- package/cjs/core/global.d.ts +0 -3
- package/cjs/core/global.js +3 -14
- package/cjs/core/global.js.map +1 -1
- package/cjs/core/stage.d.ts +3 -8
- package/cjs/core/stage.js +20 -34
- package/cjs/core/stage.js.map +1 -1
- package/cjs/graphic/arc.d.ts +2 -1
- package/cjs/graphic/arc.js +2 -3
- package/cjs/graphic/arc.js.map +1 -1
- package/cjs/graphic/area.d.ts +2 -1
- package/cjs/graphic/area.js +1 -4
- package/cjs/graphic/area.js.map +1 -1
- package/cjs/graphic/circle.d.ts +2 -1
- package/cjs/graphic/circle.js +2 -5
- package/cjs/graphic/circle.js.map +1 -1
- package/cjs/graphic/config.js +1 -2
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/graphic-service/graphic-module.js +2 -1
- package/cjs/graphic/graphic-service/graphic-module.js.map +1 -1
- package/cjs/graphic/graphic-service/graphic-service.js +3 -2
- package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +12 -9
- package/cjs/graphic/graphic.js +105 -48
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/group.js +8 -8
- package/cjs/graphic/group.js.map +1 -1
- package/cjs/graphic/line.d.ts +2 -1
- package/cjs/graphic/line.js +1 -5
- package/cjs/graphic/line.js.map +1 -1
- package/cjs/graphic/rect.js +2 -5
- package/cjs/graphic/rect.js.map +1 -1
- package/cjs/graphic/richtext/icon.d.ts +1 -1
- package/cjs/graphic/richtext/icon.js.map +1 -1
- package/cjs/graphic/richtext/paragraph.js +2 -2
- package/cjs/graphic/richtext/paragraph.js.map +1 -1
- package/cjs/graphic/star.d.ts +2 -1
- package/cjs/graphic/star.js +2 -4
- package/cjs/graphic/star.js.map +1 -1
- package/cjs/index.d.ts +3 -2
- package/cjs/index.js +16 -14
- package/cjs/index.js.map +1 -1
- package/cjs/interface/animate.d.ts +160 -1
- package/cjs/interface/animate.js +4 -1
- package/cjs/interface/animate.js.map +1 -1
- package/cjs/interface/context.d.ts +0 -1
- package/cjs/interface/context.js.map +1 -1
- package/cjs/interface/global.d.ts +0 -2
- package/cjs/interface/global.js.map +1 -1
- package/cjs/interface/graphic.d.ts +3 -11
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/index.d.ts +1 -1
- package/cjs/interface/index.js +9 -9
- package/cjs/interface/index.js.map +1 -1
- package/cjs/interface/render.d.ts +0 -7
- package/cjs/interface/render.js.map +1 -1
- package/cjs/interface/stage.d.ts +1 -4
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/modules.d.ts +1 -2
- package/cjs/modules.js +3 -4
- package/cjs/modules.js.map +1 -1
- package/cjs/plugins/builtin-plugin/auto-render-plugin.js +8 -9
- package/cjs/plugins/builtin-plugin/auto-render-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js +11 -14
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/edit-module.js +4 -4
- package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +10 -13
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +1 -0
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/incremental-auto-render-plugin.js +5 -8
- package/cjs/plugins/builtin-plugin/incremental-auto-render-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +1 -0
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js +3 -0
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +1 -0
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +2 -2
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +5 -6
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/cjs/render/contributions/render/arc-render.d.ts +2 -4
- package/cjs/render/contributions/render/arc-render.js +17 -19
- package/cjs/render/contributions/render/arc-render.js.map +1 -1
- package/cjs/render/contributions/render/area-render.js +2 -2
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/base-render.d.ts +2 -2
- package/cjs/render/contributions/render/base-render.js +2 -2
- package/cjs/render/contributions/render/base-render.js.map +1 -1
- package/cjs/render/contributions/render/draw-contribution.d.ts +0 -1
- package/cjs/render/contributions/render/draw-contribution.js +19 -23
- package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/draw-interceptor.js +1 -2
- package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
- package/cjs/render/contributions/render/group-render.d.ts +2 -2
- package/cjs/render/contributions/render/group-render.js +11 -15
- package/cjs/render/contributions/render/group-render.js.map +1 -1
- package/cjs/render/contributions/render/line-render.js +1 -1
- package/cjs/render/contributions/render/line-render.js.map +1 -1
- package/cjs/render/contributions/render/rect-render.d.ts +1 -3
- package/cjs/render/contributions/render/rect-render.js +15 -17
- package/cjs/render/contributions/render/rect-render.js.map +1 -1
- package/cjs/render/contributions/render/symbol-render.d.ts +2 -4
- package/cjs/render/contributions/render/symbol-render.js +11 -16
- package/cjs/render/contributions/render/symbol-render.js.map +1 -1
- package/cjs/render/render-service.d.ts +1 -1
- package/cjs/render/render-service.js.map +1 -1
- package/dist/index.es.js +8868 -6022
- package/es/animate/Ticker/default-ticker.d.ts +40 -0
- package/es/animate/Ticker/default-ticker.js +138 -0
- package/es/animate/Ticker/default-ticker.js.map +1 -0
- package/es/animate/Ticker/index.d.ts +5 -0
- package/es/animate/Ticker/index.js +10 -0
- package/es/animate/Ticker/index.js.map +1 -0
- package/es/animate/Ticker/manual-ticker-handler.d.ts +15 -0
- package/es/animate/Ticker/manual-ticker-handler.js +28 -0
- package/es/animate/Ticker/manual-ticker-handler.js.map +1 -0
- package/es/animate/Ticker/manual-ticker.d.ts +19 -0
- package/es/animate/Ticker/manual-ticker.js +31 -0
- package/es/animate/Ticker/manual-ticker.js.map +1 -0
- package/es/animate/Ticker/raf-tick-handler.d.ts +9 -0
- package/es/animate/Ticker/raf-tick-handler.js +22 -0
- package/es/animate/Ticker/raf-tick-handler.js.map +1 -0
- package/es/animate/Ticker/timeout-tick-handler.d.ts +9 -0
- package/es/animate/Ticker/timeout-tick-handler.js +20 -0
- package/es/animate/Ticker/timeout-tick-handler.js.map +1 -0
- package/es/animate/Ticker/type.d.ts +6 -0
- package/es/{interface/animation/ticker.js → animate/Ticker/type.js} +1 -1
- package/es/animate/Ticker/type.js.map +1 -0
- package/es/animate/animate.d.ts +147 -0
- package/es/animate/animate.js +398 -0
- package/es/animate/animate.js.map +1 -0
- package/es/animate/config.d.ts +2 -1
- package/es/animate/config.js +5 -0
- package/es/animate/config.js.map +1 -1
- package/es/animate/custom-animate.d.ts +236 -0
- package/es/animate/custom-animate.js +703 -0
- package/es/animate/custom-animate.js.map +1 -0
- package/es/animate/default-ticker.d.ts +2 -0
- package/es/animate/default-ticker.js +12 -0
- package/es/animate/default-ticker.js.map +1 -0
- package/es/animate/easing-func.d.ts +1 -0
- package/es/animate/easing-func.js +10 -0
- package/es/animate/easing-func.js.map +1 -0
- package/es/animate/easing.d.ts +49 -0
- package/es/animate/easing.js +134 -0
- package/es/animate/easing.js.map +1 -0
- package/es/animate/group-fade.d.ts +16 -0
- package/es/animate/group-fade.js +56 -0
- package/es/animate/group-fade.js.map +1 -0
- package/es/animate/index.d.ts +8 -0
- package/es/animate/index.js +16 -0
- package/es/animate/index.js.map +1 -0
- package/es/animate/morphing.d.ts +52 -0
- package/es/animate/morphing.js +295 -0
- package/es/animate/morphing.js.map +1 -0
- package/es/animate/timeline.d.ts +17 -0
- package/es/animate/timeline.js +42 -0
- package/es/animate/timeline.js.map +1 -0
- package/es/application.d.ts +1 -2
- package/es/application.js.map +1 -1
- package/es/canvas/constants.js +2 -1
- package/es/canvas/empty-context.d.ts +0 -1
- package/es/canvas/empty-context.js +0 -4
- package/es/canvas/empty-context.js.map +1 -1
- package/es/color-string/interpolate.d.ts +0 -1
- package/es/color-string/interpolate.js +1 -8
- package/es/color-string/interpolate.js.map +1 -1
- package/es/color-string/store.js +1 -2
- package/es/common/custom-path2d.js +2 -2
- package/es/common/custom-path2d.js.map +1 -1
- package/es/common/enums.d.ts +16 -0
- package/es/common/enums.js +20 -0
- package/es/common/enums.js.map +1 -1
- package/es/common/morphing-utils.js +124 -29
- package/es/common/morphing-utils.js.map +1 -1
- package/es/common/polygon.js +3 -6
- package/es/common/polygon.js.map +1 -1
- package/es/common/segment/curve/cubic-bezier.d.ts +2 -1
- package/es/common/segment/curve/cubic-bezier.js +8 -1
- package/es/common/segment/curve/cubic-bezier.js.map +1 -1
- package/es/common/segment/curve/quadratic-bezier.d.ts +0 -1
- package/es/common/segment/curve/quadratic-bezier.js +2 -5
- package/es/common/segment/curve/quadratic-bezier.js.map +1 -1
- package/es/common/segment/index.d.ts +0 -1
- package/es/common/segment/index.js +0 -2
- package/es/common/segment/index.js.map +1 -1
- package/es/common/shape/arc.d.ts +1 -1
- package/es/common/shape/arc.js +3 -7
- package/es/common/shape/arc.js.map +1 -1
- package/es/common/simplify.js +2 -1
- package/es/common/sort.js +1 -1
- package/es/common/split-path.js +2 -2
- package/es/common/split-path.js.map +1 -1
- package/es/common/store.js +1 -1
- package/es/common/text.js +1 -1
- package/es/common/utils.d.ts +2 -0
- package/es/common/utils.js +5 -1
- package/es/common/utils.js.map +1 -1
- package/es/core/application.js +1 -1
- package/es/core/camera.js +1 -1
- package/es/core/global.d.ts +0 -3
- package/es/core/global.js +2 -15
- package/es/core/global.js.map +1 -1
- package/es/core/stage.d.ts +3 -8
- package/es/core/stage.js +22 -35
- package/es/core/stage.js.map +1 -1
- package/es/graphic/arc.d.ts +2 -1
- package/es/graphic/arc.js +2 -3
- package/es/graphic/arc.js.map +1 -1
- package/es/graphic/area.d.ts +2 -1
- package/es/graphic/area.js +1 -4
- package/es/graphic/area.js.map +1 -1
- package/es/graphic/circle.d.ts +2 -1
- package/es/graphic/circle.js +2 -4
- package/es/graphic/circle.js.map +1 -1
- package/es/graphic/config.js +1 -2
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/graphic-service/graphic-module.js +1 -1
- package/es/graphic/graphic-service/graphic-module.js.map +1 -1
- package/es/graphic/graphic-service/graphic-service.js +4 -1
- package/es/graphic/graphic-service/graphic-service.js.map +1 -1
- package/es/graphic/graphic.d.ts +12 -9
- package/es/graphic/graphic.js +109 -52
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/group.js +7 -7
- package/es/graphic/group.js.map +1 -1
- package/es/graphic/line.d.ts +2 -1
- package/es/graphic/line.js +1 -5
- package/es/graphic/line.js.map +1 -1
- package/es/graphic/rect.js +2 -5
- package/es/graphic/rect.js.map +1 -1
- package/es/graphic/richtext/icon.d.ts +1 -1
- package/es/graphic/richtext/icon.js.map +1 -1
- package/es/graphic/richtext/paragraph.js +2 -2
- package/es/graphic/richtext/paragraph.js.map +1 -1
- package/es/graphic/star.d.ts +2 -1
- package/es/graphic/star.js +2 -4
- package/es/graphic/star.js.map +1 -1
- package/es/index.d.ts +3 -2
- package/es/index.js +6 -4
- package/es/index.js.map +1 -1
- package/es/interface/animate.d.ts +160 -1
- package/es/interface/animate.js +1 -2
- package/es/interface/animate.js.map +1 -1
- package/es/interface/context.d.ts +0 -1
- package/es/interface/context.js.map +1 -1
- package/es/interface/global.d.ts +0 -2
- package/es/interface/global.js.map +1 -1
- package/es/interface/graphic.d.ts +3 -11
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/index.d.ts +1 -1
- package/es/interface/index.js +2 -2
- package/es/interface/index.js.map +1 -1
- package/es/interface/render.d.ts +0 -7
- package/es/interface/render.js.map +1 -1
- package/es/interface/stage.d.ts +1 -4
- package/es/interface/stage.js.map +1 -1
- package/es/modules.d.ts +1 -2
- package/es/modules.js +0 -6
- package/es/modules.js.map +1 -1
- package/es/plugins/builtin-plugin/auto-render-plugin.js +8 -8
- package/es/plugins/builtin-plugin/auto-render-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.js +12 -13
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/edit-module.js +4 -4
- package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/es/plugins/builtin-plugin/flex-layout-plugin.js +11 -12
- package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/html-attribute-plugin.js +1 -0
- package/es/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/incremental-auto-render-plugin.js +5 -8
- package/es/plugins/builtin-plugin/incremental-auto-render-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +1 -0
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js +3 -0
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +1 -0
- package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +2 -2
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +5 -4
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/es/render/contributions/render/arc-render.d.ts +2 -4
- package/es/render/contributions/render/arc-render.js +17 -19
- package/es/render/contributions/render/arc-render.js.map +1 -1
- package/es/render/contributions/render/area-render.js +2 -2
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/base-render.d.ts +2 -2
- package/es/render/contributions/render/base-render.js +2 -2
- package/es/render/contributions/render/base-render.js.map +1 -1
- package/es/render/contributions/render/draw-contribution.d.ts +0 -1
- package/es/render/contributions/render/draw-contribution.js +19 -23
- package/es/render/contributions/render/draw-contribution.js.map +1 -1
- package/es/render/contributions/render/draw-interceptor.js +1 -2
- package/es/render/contributions/render/draw-interceptor.js.map +1 -1
- package/es/render/contributions/render/group-render.d.ts +2 -2
- package/es/render/contributions/render/group-render.js +11 -15
- package/es/render/contributions/render/group-render.js.map +1 -1
- package/es/render/contributions/render/line-render.js +1 -1
- package/es/render/contributions/render/line-render.js.map +1 -1
- package/es/render/contributions/render/rect-render.d.ts +1 -3
- package/es/render/contributions/render/rect-render.js +14 -17
- package/es/render/contributions/render/rect-render.js.map +1 -1
- package/es/render/contributions/render/symbol-render.d.ts +2 -4
- package/es/render/contributions/render/symbol-render.js +11 -16
- package/es/render/contributions/render/symbol-render.js.map +1 -1
- package/es/render/render-service.d.ts +1 -1
- package/es/render/render-service.js.map +1 -1
- package/package.json +4 -4
- package/cjs/common/diff.d.ts +0 -1
- package/cjs/common/diff.js +0 -19
- package/cjs/common/diff.js.map +0 -1
- package/cjs/common/performance-raf.d.ts +0 -8
- package/cjs/common/performance-raf.js +0 -32
- package/cjs/common/performance-raf.js.map +0 -1
- package/cjs/interface/animation/animate.d.ts +0 -117
- package/cjs/interface/animation/animate.js +0 -10
- package/cjs/interface/animation/animate.js.map +0 -1
- package/cjs/interface/animation/easing.d.ts +0 -3
- package/cjs/interface/animation/easing.js +0 -6
- package/cjs/interface/animation/easing.js.map +0 -1
- package/cjs/interface/animation/index.d.ts +0 -5
- package/cjs/interface/animation/index.js.map +0 -1
- package/cjs/interface/animation/ticker.d.ts +0 -39
- package/cjs/interface/animation/ticker.js.map +0 -1
- package/cjs/interface/animation/timeline.d.ts +0 -17
- package/cjs/interface/animation/timeline.js +0 -6
- package/cjs/interface/animation/timeline.js.map +0 -1
- package/cjs/interface/animation/type.d.ts +0 -13
- package/cjs/interface/animation/type.js +0 -15
- package/cjs/interface/animation/type.js.map +0 -1
- package/es/common/diff.d.ts +0 -1
- package/es/common/diff.js +0 -11
- package/es/common/diff.js.map +0 -1
- package/es/common/performance-raf.d.ts +0 -8
- package/es/common/performance-raf.js +0 -24
- package/es/common/performance-raf.js.map +0 -1
- package/es/interface/animation/animate.d.ts +0 -117
- package/es/interface/animation/animate.js +0 -6
- package/es/interface/animation/animate.js.map +0 -1
- package/es/interface/animation/easing.d.ts +0 -3
- package/es/interface/animation/easing.js +0 -2
- package/es/interface/animation/easing.js.map +0 -1
- package/es/interface/animation/index.d.ts +0 -5
- package/es/interface/animation/index.js +0 -10
- package/es/interface/animation/index.js.map +0 -1
- package/es/interface/animation/ticker.d.ts +0 -39
- package/es/interface/animation/ticker.js.map +0 -1
- package/es/interface/animation/timeline.d.ts +0 -17
- package/es/interface/animation/timeline.js +0 -2
- package/es/interface/animation/timeline.js.map +0 -1
- package/es/interface/animation/type.d.ts +0 -13
- package/es/interface/animation/type.js +0 -14
- package/es/interface/animation/type.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA+CA,2CAAyB;AACzB,2CAAyB;AACzB,8CAA4B;AAC5B,4CAA0B;AAC1B,kDAAgC;AAChC,0CAAwB;AACxB,0CAAwB;AACxB,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AACvB,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,0CAAwB;AACxB,oDAAkC;AAClC,8CAA4B;AAC5B,8CAA4B;AAC5B,yCAAuB;AACvB,0CAAwB;AACxB,2CAAyB;AACzB,iDAA+B;AAC/B,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB
|
|
1
|
+
{"version":3,"sources":["../src/interface/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA+CA,2CAAyB;AACzB,2CAAyB;AACzB,8CAA4B;AAC5B,4CAA0B;AAC1B,kDAAgC;AAChC,0CAAwB;AACxB,0CAAwB;AACxB,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AACvB,0CAAwB;AACxB,2CAAyB;AACzB,4CAA0B;AAC1B,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,0CAAwB;AACxB,oDAAkC;AAClC,8CAA4B;AAC5B,8CAA4B;AAC5B,yCAAuB;AACvB,0CAAwB;AACxB,2CAAyB;AACzB,iDAA+B;AAC/B,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB","file":"index.js","sourcesContent":["// export type MaybePromise<T> = T | PromiseLike<T>;\n\n// // 所有的接口都应当继承这个,避免内存没有释放\n// export interface Disposable {\n// dispose: (params?: any) => void;\n// }\n\n// export { INode } from './node-tree';\n// export { IGraphic, IGraphicAttribute, IFillStyle, IStrokeStyle, IStyle, ITransform } from './graphic';\n// export { IArc, IArcAttribute, IArcGraphicAttribute, IArcCache } from './graphic/arc';\n// export { IArea, IAreaAttribute, IAreaGraphicAttribute, IAreaCacheItem, IAreaSegment } from './graphic/area';\n// export { ICircle, ICircleAttribute, ICircleGraphicAttribute } from './graphic/circle';\n// export { IGroup, IGroupAttribute } from './graphic/group';\n// export { IImage, IImageAttribute, IImageGraphicAttribute, IRepeatType } from './graphic/image';\n// export { ILine, ILineAttribute, ILineGraphicAttribute, ISegment } from './graphic/line';\n// export { IPath, IPathAttribute, IPathGraphicAttribute } from './graphic/path';\n// export { IRect, IRectAttribute, IRectGraphicAttribute } from './graphic/rect';\n// export {\n// IRichText,\n// IRichTextAttribute,\n// RichTextCharacter,\n// RichTextFontStyle,\n// RichTextGlobalAlignType,\n// RichTextGlobalBaselineType,\n// RichTextScript,\n// RichTextTextAlign,\n// RichTextTextDecoration,\n// RichTextVerticalDirection,\n// RichTextWordBreak,\n// IRichTextGraphicAttribute\n// } from './graphic/richText';\n// export { ISymbol, ISymbolAttribute, ISymbolGraphicAttribute, SymbolType } from './graphic/symbol';\n// export { IText, ITextAttribute, ITextGraphicAttribute, ITextCache } from './graphic/text';\n// export { ILayer, ILayerDrawParams } from './layer';\n// export { IStage, IStageParams, IExportType } from './stage';\n\n// // export * from './graphic';\n// export { ICanvas, ICanvasLike } from './canvas';\n// export { IContext2d, IContextLike, ICommonStyleParams, IStrokeStyleParams, ITextStyleParams } from './context';\n\n// export { IPath2D, ICustomPath2D, CommandType, ICurvePath, ICurve } from './path';\n\n// export { IColor, IColorStop, IConicalGradient, ILinearGradient, IRadialGradient } from './color';\n\n// export { ICurveType } from './common';\n// // export { IAreaCacheItem } from './graphic';\n\nexport * from './global';\nexport * from './common';\nexport * from './node-tree';\nexport * from './graphic';\nexport * from './graphic/index';\nexport * from './layer';\nexport * from './stage';\nexport * from './canvas';\nexport * from './context';\nexport * from './path';\nexport * from './color';\nexport * from './common';\nexport * from './animate';\nexport * from './camera';\nexport * from './matrix';\nexport * from './light';\nexport * from './curve';\nexport * from './graphic-service';\nexport * from './sync-hook';\nexport * from './allocator';\nexport * from './core';\nexport * from './event';\nexport * from './loader';\nexport * from './contribution';\nexport * from './render';\nexport * from './plugin';\nexport * from './picker';\nexport * from './text';\nexport * from './window';\n"]}
|
|
@@ -25,7 +25,6 @@ export interface IRenderService {
|
|
|
25
25
|
renderTreeRoots: IGraphic[];
|
|
26
26
|
renderLists: IGraphic[];
|
|
27
27
|
drawParams: IRenderServiceDrawParams;
|
|
28
|
-
drawContribution: IDrawContribution;
|
|
29
28
|
prepare: (updateBounds: boolean) => void;
|
|
30
29
|
prepareRenderList: () => void;
|
|
31
30
|
beforeDraw: (params: IRenderServiceDrawParams) => void;
|
|
@@ -45,7 +44,6 @@ export interface IDrawContext extends IRenderServiceDrawParams {
|
|
|
45
44
|
in3dInterceptor?: boolean;
|
|
46
45
|
drawContribution?: IDrawContribution;
|
|
47
46
|
hack_pieFace?: 'inside' | 'bottom' | 'top' | 'outside';
|
|
48
|
-
isGroupScroll?: boolean;
|
|
49
47
|
}
|
|
50
48
|
export interface IDrawContribution {
|
|
51
49
|
hooks?: {
|
|
@@ -70,11 +68,6 @@ export interface IGraphicRenderDrawParams {
|
|
|
70
68
|
drawingCb?: () => void;
|
|
71
69
|
skipDraw?: boolean;
|
|
72
70
|
theme?: IFullThemeSpec;
|
|
73
|
-
renderInGroupParams?: {
|
|
74
|
-
skipSort?: boolean;
|
|
75
|
-
nextM?: IMatrixLike;
|
|
76
|
-
};
|
|
77
|
-
renderInGroup?: (skipSort: boolean, group: IGroup, drawContext: IDrawContext, nextM: IMatrixLike) => void;
|
|
78
71
|
}
|
|
79
72
|
export interface IGraphicRender {
|
|
80
73
|
type: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/render.ts"],"names":[],"mappings":"","file":"render.js","sourcesContent":["import type { IAABBBounds, IBounds, IMatrix, IMatrixLike } from '@visactor/vutils';\nimport type { IColor } from './color';\nimport type { IContext2d } from './context';\nimport type { IGraphic, IGraphicAttribute } from './graphic';\nimport type { IMarkAttribute, IThemeAttribute } from './graphic/creator';\nimport type { IFullThemeSpec } from './graphic/theme';\nimport type { ILayer } from './layer';\nimport type { IStage } from './stage';\nimport type { IGroup } from './graphic/group';\nimport type { MaybePromise } from './common';\nimport type { ISyncHook } from './sync-hook';\n\n// 用于绘制的参数,提供context\n// TODO: 考虑是否可以隐藏上下文类型\nexport interface IRenderServiceDrawParams {\n context?: IContext2d;\n\n // 绘制的区域以及是否需要清屏\n clear?: string | IColor | boolean;\n viewBox: IBounds;\n transMatrix?: IMatrixLike;\n stage: IStage;\n layer: ILayer;\n renderService: IRenderService;\n updateBounds: boolean;\n renderStyle?: string;\n}\n\nexport interface IRenderService {\n dirtyBounds: IBounds;\n renderTreeRoots: IGraphic[]; // 此次render的数组\n renderLists: IGraphic[];\n drawParams: IRenderServiceDrawParams;\n
|
|
1
|
+
{"version":3,"sources":["../src/interface/render.ts"],"names":[],"mappings":"","file":"render.js","sourcesContent":["import type { IAABBBounds, IBounds, IMatrix, IMatrixLike } from '@visactor/vutils';\nimport type { IColor } from './color';\nimport type { IContext2d } from './context';\nimport type { IGraphic, IGraphicAttribute } from './graphic';\nimport type { IMarkAttribute, IThemeAttribute } from './graphic/creator';\nimport type { IFullThemeSpec } from './graphic/theme';\nimport type { ILayer } from './layer';\nimport type { IStage } from './stage';\nimport type { IGroup } from './graphic/group';\nimport type { MaybePromise } from './common';\nimport type { ISyncHook } from './sync-hook';\n\n// 用于绘制的参数,提供context\n// TODO: 考虑是否可以隐藏上下文类型\nexport interface IRenderServiceDrawParams {\n context?: IContext2d;\n\n // 绘制的区域以及是否需要清屏\n clear?: string | IColor | boolean;\n viewBox: IBounds;\n transMatrix?: IMatrixLike;\n stage: IStage;\n layer: ILayer;\n renderService: IRenderService;\n updateBounds: boolean;\n renderStyle?: string;\n}\n\nexport interface IRenderService {\n dirtyBounds: IBounds;\n renderTreeRoots: IGraphic[]; // 此次render的数组\n renderLists: IGraphic[];\n drawParams: IRenderServiceDrawParams;\n\n prepare: (updateBounds: boolean) => void;\n prepareRenderList: () => void;\n beforeDraw: (params: IRenderServiceDrawParams) => void;\n draw: (params: IRenderServiceDrawParams) => void;\n afterDraw: (params: IRenderServiceDrawParams) => void;\n render: (groups: IGroup[], params: IRenderServiceDrawParams) => MaybePromise<void>;\n reInit: () => void;\n}\n\nexport interface IDrawContext extends IRenderServiceDrawParams {\n startAtId?: number;\n break?: boolean;\n restartIncremental?: boolean;\n // multi图元开始的位置\n multiGraphicOptions?: {\n startAtIdx: number;\n length: number;\n };\n in3dInterceptor?: boolean;\n drawContribution?: IDrawContribution;\n // hack内容\n hack_pieFace?: 'inside' | 'bottom' | 'top' | 'outside';\n}\n\nexport interface IDrawContribution {\n hooks?: {\n completeDraw: ISyncHook<[]>;\n };\n dirtyBounds?: IAABBBounds;\n backupDirtyBounds?: IAABBBounds;\n rendering?: boolean;\n currentRenderMap: Map<number, IGraphicRender>;\n defaultRenderMap: Map<number, IGraphicRender>;\n styleRenderMap: Map<string, Map<number, IGraphicRender>>;\n draw: (renderService: IRenderService, drawParams: IDrawContext) => MaybePromise<void>;\n afterDraw?: (renderService: IRenderService, drawParams: IDrawContext) => MaybePromise<void>;\n getRenderContribution: (graphic: IGraphic) => IGraphicRender | null;\n renderGroup: (group: IGroup, drawContext: IDrawContext, matrix: IMatrixLike, skipSort?: boolean) => void;\n renderItem: (graphic: IGraphic, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) => void;\n reInit: () => void;\n}\n\nexport interface IGraphicRenderDrawParams {\n beforeDrawCb?: () => void;\n afterDrawCb?: () => void;\n drawingCb?: () => void;\n skipDraw?: boolean;\n theme?: IFullThemeSpec;\n}\n\nexport interface IGraphicRender {\n type: string; // 图元类型\n numberType: number;\n style?: string;\n z?: number;\n draw: (\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams\n ) => void;\n drawShape?: (\n graphic: IGraphic,\n ctx: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) => void;\n\n reInit: () => void;\n}\n\nexport interface IBeforeRenderConstribution {\n apply: (renderService: IRenderService) => MaybePromise<void>;\n}\n\nexport interface IRenderSelector {\n selector: (graphic: IGraphic) => IGraphicRender | null;\n}\n\nexport interface IDrawItemInterceptorContribution {\n order: number;\n beforeDrawItem?: (\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) => boolean;\n afterDrawItem?: (\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) => boolean;\n}\n"]}
|
package/cjs/interface/stage.d.ts
CHANGED
|
@@ -7,13 +7,12 @@ import type { vec3 } from './matrix';
|
|
|
7
7
|
import type { IDirectionLight } from './light';
|
|
8
8
|
import type { ISyncHook } from './sync-hook';
|
|
9
9
|
import type { IDrawContext, IRenderService } from './render';
|
|
10
|
-
import type { ITicker, ITimeline } from './
|
|
10
|
+
import type { ITicker, ITimeline } from './animate';
|
|
11
11
|
import type { IPickerService, PickResult } from './picker';
|
|
12
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';
|
|
16
|
-
import type { IGraphicService } from './graphic-service';
|
|
17
16
|
export type IExportType = 'canvas' | 'imageData';
|
|
18
17
|
export type IStageCreateContext = {
|
|
19
18
|
appName?: 'vchart' | 'vgrammar' | 'vtable' | string;
|
|
@@ -47,7 +46,6 @@ export interface IStageParams {
|
|
|
47
46
|
supportsTouchEvents?: boolean;
|
|
48
47
|
supportsPointerEvents?: boolean;
|
|
49
48
|
context?: IStageCreateContext;
|
|
50
|
-
rafId?: number;
|
|
51
49
|
}
|
|
52
50
|
export type EventConfig = {
|
|
53
51
|
autoPreventDefault?: boolean;
|
|
@@ -110,7 +108,6 @@ export interface IStage extends INode {
|
|
|
110
108
|
ticker: ITicker;
|
|
111
109
|
increaseAutoRender: boolean;
|
|
112
110
|
readonly renderService: IRenderService;
|
|
113
|
-
readonly graphicService: IGraphicService;
|
|
114
111
|
getPickerService: () => IPickerService;
|
|
115
112
|
readonly pluginService: IPluginService;
|
|
116
113
|
readonly layerService: ILayerService;
|
|
@@ -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 './
|
|
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 autoRefresh: 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 // tick渲染模式,effect会在tick之后立刻执行render,保证动画效果正常。performance模式中tick和render均是RAF,属性可能会被篡改\n tickRenderMode?: 'effect' | 'performance';\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 getPickerService: () => 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: (sk?: number) => 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 pauseTriggerEvent: () => void;\n resumeTriggerEvent: () => void;\n}\n\nexport declare function combineStage(srages: IStage[], params: { canvas: string | HTMLCanvasElement }): IStage;\n"]}
|
package/cjs/modules.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IGlobal, IGraphicService
|
|
1
|
+
import type { IGlobal, IGraphicService } from './interface';
|
|
2
2
|
import type { IGraphicUtil, ILayerService, ITransformUtil } from './interface/core';
|
|
3
3
|
export declare function preLoadAllModule(): void;
|
|
4
4
|
export declare namespace preLoadAllModule {
|
|
@@ -8,5 +8,4 @@ export declare const vglobal: IGlobal;
|
|
|
8
8
|
export declare const graphicUtil: IGraphicUtil;
|
|
9
9
|
export declare const transformUtil: ITransformUtil;
|
|
10
10
|
export declare const graphicService: IGraphicService;
|
|
11
|
-
export declare const renderService: IRenderService;
|
|
12
11
|
export declare const layerService: ILayerService;
|
package/cjs/modules.js
CHANGED
|
@@ -8,9 +8,9 @@ var __importDefault = this && this.__importDefault || function(mod) {
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", {
|
|
10
10
|
value: !0
|
|
11
|
-
}), exports.layerService = exports.
|
|
11
|
+
}), exports.layerService = exports.graphicService = exports.transformUtil = exports.graphicUtil = exports.vglobal = exports.preLoadAllModule = void 0;
|
|
12
12
|
|
|
13
|
-
const core_modules_1 = __importDefault(require("./core/core-modules")), render_modules_1 = __importDefault(require("./render/render-modules")), pick_modules_1 = __importDefault(require("./picker/pick-modules")), graphic_module_1 = __importDefault(require("./graphic/graphic-service/graphic-module")), plugin_modules_1 = __importDefault(require("./plugins/plugin-modules")), modules_1 = __importDefault(require("./core/contributions/modules")), modules_2 = __importDefault(require("./render/contributions/modules")), constants_1 = require("./core/constants"), application_1 = require("./application"), constants_2 = require("./graphic/constants"), constants_3 = require("./core/constants"), container_1 = require("./container"), constants_4 = require("./constants")
|
|
13
|
+
const core_modules_1 = __importDefault(require("./core/core-modules")), render_modules_1 = __importDefault(require("./render/render-modules")), pick_modules_1 = __importDefault(require("./picker/pick-modules")), graphic_module_1 = __importDefault(require("./graphic/graphic-service/graphic-module")), plugin_modules_1 = __importDefault(require("./plugins/plugin-modules")), modules_1 = __importDefault(require("./core/contributions/modules")), modules_2 = __importDefault(require("./render/contributions/modules")), constants_1 = require("./core/constants"), application_1 = require("./application"), constants_2 = require("./graphic/constants"), constants_3 = require("./core/constants"), container_1 = require("./container"), constants_4 = require("./constants");
|
|
14
14
|
|
|
15
15
|
function preLoadAllModule() {
|
|
16
16
|
preLoadAllModule.__loaded || (preLoadAllModule.__loaded = !0, container_1.container.load(core_modules_1.default),
|
|
@@ -24,7 +24,6 @@ exports.vglobal = container_1.container.get(constants_4.VGlobal), application_1.
|
|
|
24
24
|
exports.graphicUtil = container_1.container.get(constants_3.GraphicUtil), application_1.application.graphicUtil = exports.graphicUtil,
|
|
25
25
|
exports.transformUtil = container_1.container.get(constants_3.TransformUtil), application_1.application.transformUtil = exports.transformUtil,
|
|
26
26
|
exports.graphicService = container_1.container.get(constants_2.GraphicService),
|
|
27
|
-
application_1.application.graphicService = exports.graphicService, exports.
|
|
28
|
-
application_1.application.renderService = exports.renderService, exports.layerService = container_1.container.get(constants_1.LayerService),
|
|
27
|
+
application_1.application.graphicService = exports.graphicService, exports.layerService = container_1.container.get(constants_1.LayerService),
|
|
29
28
|
application_1.application.layerService = exports.layerService;
|
|
30
29
|
//# sourceMappingURL=modules.js.map
|
package/cjs/modules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/modules.ts"],"names":[],"mappings":";;;;;;AAAA,uEAA6C;AAC7C,6EAAmD;AACnD,yEAA+C;AAE/C,8FAAqE;AACrE,8EAAoD;AACpD,2EAAoE;AACpE,6EAAqE;AAGrE,gDAAgD;AAIhD,+CAA4C;AAE5C,mDAAqD;AACrD,gDAA8D;AAC9D,2CAAwC;AACxC,2CAAsC;
|
|
1
|
+
{"version":3,"sources":["../src/modules.ts"],"names":[],"mappings":";;;;;;AAAA,uEAA6C;AAC7C,6EAAmD;AACnD,yEAA+C;AAE/C,8FAAqE;AACrE,8EAAoD;AACpD,2EAAoE;AACpE,6EAAqE;AAGrE,gDAAgD;AAIhD,+CAA4C;AAE5C,mDAAqD;AACrD,gDAA8D;AAC9D,2CAAwC;AACxC,2CAAsC;AAEtC,SAAgB,gBAAgB;IAC9B,IAAI,gBAAgB,CAAC,QAAQ,EAAE;QAC7B,OAAO;KACR;IACD,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAC;IACjC,qBAAS,CAAC,IAAI,CAAC,sBAAU,CAAC,CAAC;IAC3B,qBAAS,CAAC,IAAI,CAAC,wBAAa,CAAC,CAAC;IAC9B,qBAAS,CAAC,IAAI,CAAC,wBAAY,CAAC,CAAC;IAC7B,qBAAS,CAAC,IAAI,CAAC,sBAAU,CAAC,CAAC;IAE3B,qBAAS,CAAC,IAAI,CAAC,wBAAY,CAAC,CAAC;IAC7B,IAAA,iBAAwB,EAAC,qBAAS,CAAC,CAAC;IACpC,IAAA,iBAAuB,EAAC,qBAAS,CAAC,CAAC;AACrC,CAAC;AAbD,4CAaC;AAED,gBAAgB,CAAC,QAAQ,GAAG,KAAK,CAAC;AAElC,gBAAgB,EAAE,CAAC;AAKN,QAAA,OAAO,GAAG,qBAAS,CAAC,GAAG,CAAU,mBAAO,CAAC,CAAC;AACvD,yBAAW,CAAC,MAAM,GAAG,eAAO,CAAC;AAChB,QAAA,WAAW,GAAG,qBAAS,CAAC,GAAG,CAAe,uBAAW,CAAC,CAAC;AACpE,yBAAW,CAAC,WAAW,GAAG,mBAAW,CAAC;AACzB,QAAA,aAAa,GAAG,qBAAS,CAAC,GAAG,CAAiB,yBAAa,CAAC,CAAC;AAC1E,yBAAW,CAAC,aAAa,GAAG,qBAAa,CAAC;AAC7B,QAAA,cAAc,GAAG,qBAAS,CAAC,GAAG,CAAkB,0BAAc,CAAC,CAAC;AAC7E,yBAAW,CAAC,cAAc,GAAG,sBAAc,CAAC;AAa/B,QAAA,YAAY,GAAG,qBAAS,CAAC,GAAG,CAAgB,wBAAY,CAAC,CAAC;AACvE,yBAAW,CAAC,YAAY,GAAG,oBAAY,CAAC","file":"modules.js","sourcesContent":["import coreModule from './core/core-modules';\nimport renderModule from './render/render-modules';\nimport pickModule from './picker/pick-modules';\n// import allocatorModule from './allocator/allocator-modules';\nimport graphicModule from './graphic/graphic-service/graphic-module';\nimport pluginModule from './plugins/plugin-modules';\nimport loadBuiltinContributions from './core/contributions/modules';\nimport loadRenderContributions from './render/contributions/modules';\n// import loadPickContributions from './picker/contributions/modules';\n// import loadCanvasContributions from './canvas/contributions/modules';\nimport { LayerService } from './core/constants';\n// import { IMat4Allocate, IMatrixAllocate, Mat4Allocate, MatrixAllocate } from './allocator/matrix-allocate';\n// import { GlobalPickerService } from './picker/constants';\nimport type { IGlobal, IGraphicService, IPickerService } from './interface';\nimport { application } from './application';\nimport type { IGraphicUtil, ILayerService, ITransformUtil } from './interface/core';\nimport { GraphicService } from './graphic/constants';\nimport { GraphicUtil, TransformUtil } from './core/constants';\nimport { container } from './container';\nimport { VGlobal } from './constants';\n\nexport function preLoadAllModule() {\n if (preLoadAllModule.__loaded) {\n return;\n }\n preLoadAllModule.__loaded = true;\n container.load(coreModule);\n container.load(graphicModule);\n container.load(renderModule);\n container.load(pickModule);\n // container.load(allocatorModule);\n container.load(pluginModule);\n loadBuiltinContributions(container);\n loadRenderContributions(container);\n}\n\npreLoadAllModule.__loaded = false;\n\npreLoadAllModule();\n// loadPickContributions(container);\n// loadCanvasContributions(container);\n\n// 全局变量\nexport const vglobal = container.get<IGlobal>(VGlobal);\napplication.global = vglobal;\nexport const graphicUtil = container.get<IGraphicUtil>(GraphicUtil);\napplication.graphicUtil = graphicUtil;\nexport const transformUtil = container.get<ITransformUtil>(TransformUtil);\napplication.transformUtil = transformUtil;\nexport const graphicService = container.get<IGraphicService>(GraphicService);\napplication.graphicService = graphicService;\n// export const matrixAllocate = container.get<IMatrixAllocate>(MatrixAllocate);\n// export const mat4Allocate = container.get<IMat4Allocate>(Mat4Allocate);\n// export const canvasAllocate = container.get<ICanvasAllocate>(CanvasAllocate);\n// export const arcAllocate = container.get<IArcAllocate>(ArcAllocate);\n// export const areaAllocate = container.get<IAreaAllocate>(AreaAllocate);\n// export const circleAllocate = container.get<ICircleAllocate>(CircleAllocate);\n// export const lineAllocate = container.get<ILineAllocate>(LineAllocate);\n// export const pathAllocate = container.get<IPathAllocate>(PathAllocate);\n// export const rectAllocate = container.get<IRectAllocate>(RectAllocate);\n// export const symbolAllocate = container.get<ISymbolAllocate>(SymbolAllocate);\n// export const textAllocate = container.get<ITextAllocate>(TextAllocate);\n// export const pickerService = container.get<IPickerService>(GlobalPickerService);\nexport const layerService = container.get<ILayerService>(LayerService);\napplication.layerService = layerService;\n"]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.AutoRenderPlugin = void 0;
|
|
6
6
|
|
|
7
|
-
const generator_1 = require("../../common/generator");
|
|
7
|
+
const generator_1 = require("../../common/generator"), application_1 = require("../../application");
|
|
8
8
|
|
|
9
9
|
class AutoRenderPlugin {
|
|
10
10
|
constructor() {
|
|
@@ -14,16 +14,15 @@ class AutoRenderPlugin {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
activate(context) {
|
|
17
|
-
this.pluginService = context
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
stage.graphicService.hooks.onSetStage.tap(this.key, this.handleChange), stage.graphicService.hooks.onRemove.tap(this.key, this.handleChange));
|
|
17
|
+
this.pluginService = context, application_1.application.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handleChange),
|
|
18
|
+
application_1.application.graphicService.hooks.onSetStage.tap(this.key, this.handleChange),
|
|
19
|
+
application_1.application.graphicService.hooks.onRemove.tap(this.key, this.handleChange);
|
|
21
20
|
}
|
|
22
21
|
deactivate(context) {
|
|
23
|
-
const filterByName = taps => taps.filter((item => item.name !== this.key))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const filterByName = taps => taps.filter((item => item.name !== this.key));
|
|
23
|
+
application_1.application.graphicService.hooks.onAttributeUpdate.taps = filterByName(application_1.application.graphicService.hooks.onAttributeUpdate.taps),
|
|
24
|
+
application_1.application.graphicService.hooks.onSetStage.taps = filterByName(application_1.application.graphicService.hooks.onSetStage.taps),
|
|
25
|
+
application_1.application.graphicService.hooks.onRemove.taps = filterByName(application_1.application.graphicService.hooks.onRemove.taps);
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/builtin-plugin/auto-render-plugin.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;
|
|
1
|
+
{"version":3,"sources":["../src/plugins/builtin-plugin/auto-render-plugin.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AACnD,mDAAgD;AAGhD,MAAa,gBAAgB;IAA7B;QACE,SAAI,GAAuB,kBAAkB,CAAC;QAC9C,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,qBAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEpC,iBAAY,GAAG,CAAC,OAAiB,EAAE,EAAE;YACnC,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;aAC7B;YACD,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;gBACvE,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;aACjC;QACH,CAAC,CAAC;IAqBJ,CAAC;IAnBC,QAAQ,CAAC,OAAuB;QAC9B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACpF,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7E,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7E,CAAC;IACD,UAAU,CAAC,OAAuB;QAChC,MAAM,YAAY,GAAG,CAAC,IAAe,EAAE,EAAE;YACvC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACxB,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,GAAG,YAAY,CACpE,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CACxD,CAAC;QACF,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,YAAY,CAAC,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAClH,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,GAAG,YAAY,CAAC,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChH,CAAC;CACF;AAnCD,4CAmCC","file":"auto-render-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport { application } from '../../application';\nimport type { FullTap, IGraphic, IPlugin, IPluginService } from '../../interface';\n\nexport class AutoRenderPlugin implements IPlugin {\n name: 'AutoRenderPlugin' = 'AutoRenderPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n handleChange = (graphic: IGraphic) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (graphic.stage === this.pluginService.stage && graphic.stage != null) {\n graphic.stage.renderNextFrame();\n }\n };\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n application.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handleChange);\n application.graphicService.hooks.onSetStage.tap(this.key, this.handleChange);\n application.graphicService.hooks.onRemove.tap(this.key, this.handleChange);\n }\n deactivate(context: IPluginService): void {\n const filterByName = (taps: FullTap[]) => {\n return taps.filter(item => {\n return item.name !== this.key;\n });\n };\n\n application.graphicService.hooks.onAttributeUpdate.taps = filterByName(\n application.graphicService.hooks.onAttributeUpdate.taps\n );\n application.graphicService.hooks.onSetStage.taps = filterByName(application.graphicService.hooks.onSetStage.taps);\n application.graphicService.hooks.onRemove.taps = filterByName(application.graphicService.hooks.onRemove.taps);\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.DirtyBoundsPlugin = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), generator_1 = require("../../common/generator"), globalBounds = new vutils_1.AABBBounds;
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), generator_1 = require("../../common/generator"), application_1 = require("../../application"), globalBounds = new vutils_1.AABBBounds;
|
|
8
8
|
|
|
9
9
|
class DirtyBoundsPlugin {
|
|
10
10
|
constructor() {
|
|
@@ -14,27 +14,24 @@ class DirtyBoundsPlugin {
|
|
|
14
14
|
activate(context) {
|
|
15
15
|
this.pluginService = context, context.stage.hooks.afterRender.tap(this.key, (stage => {
|
|
16
16
|
stage && stage === this.pluginService.stage && stage.dirtyBounds.clear();
|
|
17
|
-
}))
|
|
18
|
-
const stage = this.pluginService.stage;
|
|
19
|
-
stage && (stage.graphicService.hooks.beforeUpdateAABBBounds.tap(this.key, ((graphic, stage, willUpdate, bounds) => {
|
|
17
|
+
})), application_1.application.graphicService.hooks.beforeUpdateAABBBounds.tap(this.key, ((graphic, stage, willUpdate, bounds) => {
|
|
20
18
|
graphic.glyphHost && (graphic = graphic.glyphHost), stage && stage === this.pluginService.stage && stage.renderCount && (graphic.isContainer && !graphic.shouldSelfChangeUpdateAABBBounds() || willUpdate && (globalBounds.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2),
|
|
21
19
|
stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix)));
|
|
22
|
-
})),
|
|
20
|
+
})), application_1.application.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, ((graphic, stage, bounds, params, selfChange) => {
|
|
23
21
|
stage && stage === this.pluginService.stage && stage.renderCount && (graphic.isContainer && !selfChange || stage.dirty(params.globalAABBBounds));
|
|
24
|
-
})),
|
|
22
|
+
})), application_1.application.graphicService.hooks.clearAABBBounds.tap(this.key, ((graphic, stage, bounds) => {
|
|
25
23
|
stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(bounds);
|
|
26
|
-
})),
|
|
24
|
+
})), application_1.application.graphicService.hooks.onRemove.tap(this.key, (graphic => {
|
|
27
25
|
const stage = graphic.stage;
|
|
28
26
|
stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(graphic.globalAABBBounds);
|
|
29
|
-
}))
|
|
27
|
+
}));
|
|
30
28
|
}
|
|
31
29
|
deactivate(context) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
stage.
|
|
36
|
-
|
|
37
|
-
stage.graphicService.hooks.onRemove.taps = stage.graphicService.hooks.onRemove.taps.filter((item => item.name !== this.key)));
|
|
30
|
+
application_1.application.graphicService.hooks.beforeUpdateAABBBounds.taps = application_1.application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
31
|
+
application_1.application.graphicService.hooks.afterUpdateAABBBounds.taps = application_1.application.graphicService.hooks.afterUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
32
|
+
application_1.application.graphicService.hooks.clearAABBBounds.taps = application_1.application.graphicService.hooks.clearAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
33
|
+
context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter((item => item.name !== this.key)),
|
|
34
|
+
application_1.application.graphicService.hooks.onRemove.taps = application_1.application.graphicService.hooks.onRemove.taps.filter((item => item.name !== this.key));
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/builtin-plugin/dirty-bounds-plugin.ts"],"names":[],"mappings":";;;AACA,6CAA8C;AAC9C,sDAAmD;
|
|
1
|
+
{"version":3,"sources":["../src/plugins/builtin-plugin/dirty-bounds-plugin.ts"],"names":[],"mappings":";;;AACA,6CAA8C;AAC9C,sDAAmD;AAEnD,mDAAgD;AAEhD,MAAM,YAAY,GAAG,IAAI,mBAAU,EAAE,CAAC;AAEtC,MAAa,iBAAiB;IAA9B;QACE,SAAI,GAAwB,mBAAmB,CAAC;QAChD,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,qBAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IAyFtC,CAAC;IAvFC,QAAQ,CAAC,OAAuB;QAC9B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE;YACpD,IAAI,CAAC,CAAC,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;gBAClD,OAAO;aACR;YACD,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,sBAAsB,CAAC,GAAG,CACzD,IAAI,CAAC,GAAG,EACR,CAAC,OAAiB,EAAE,KAAa,EAAE,UAAmB,EAAE,MAAmB,EAAE,EAAE;YAC7E,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,GAAG,OAAO,CAAC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AE;gBAClE,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACxF,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;QACH,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,GAAG,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC5G,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9FD,8CA8FC","file":"dirty-bounds-plugin.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds } from '@visactor/vutils';\nimport { Generator } from '../../common/generator';\nimport type { IGraphic, IStage, IPlugin, IPluginService } from '../../interface';\nimport { application } from '../../application';\n\nconst globalBounds = new AABBBounds();\n\nexport class DirtyBoundsPlugin implements IPlugin {\n name: 'DirtyBoundsPlugin' = 'DirtyBoundsPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n context.stage.hooks.afterRender.tap(this.key, stage => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n stage.dirtyBounds.clear();\n });\n application.graphicService.hooks.beforeUpdateAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n // group的子元素导致的bounds更新不用做dirtyBounds\n if (graphic.isContainer && !graphic.shouldSelfChangeUpdateAABBBounds()) {\n return;\n }\n if (willUpdate) {\n globalBounds.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2);\n stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix);\n }\n }\n );\n application.graphicService.hooks.afterUpdateAABBBounds.tap(\n this.key,\n (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => {\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n // group的子元素导致的bounds更新不用做dirtyBounds\n if (graphic.isContainer && !selfChange) {\n return;\n }\n stage.dirty(params.globalAABBBounds);\n }\n );\n application.graphicService.hooks.clearAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, bounds: IAABBBounds) => {\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n if (stage) {\n stage.dirty(bounds);\n }\n }\n );\n application.graphicService.hooks.onRemove.tap(this.key, (graphic: IGraphic) => {\n const stage = graphic.stage;\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n if (stage) {\n stage.dirty(graphic.globalAABBBounds);\n }\n });\n }\n deactivate(context: IPluginService): void {\n application.graphicService.hooks.beforeUpdateAABBBounds.taps =\n application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.afterUpdateAABBBounds.taps =\n application.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.clearAABBBounds.taps =\n application.graphicService.hooks.clearAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.onRemove.taps = application.graphicService.hooks.onRemove.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n}\n"]}
|
|
@@ -131,9 +131,9 @@ class EditModule {
|
|
|
131
131
|
}));
|
|
132
132
|
}, this.container = null != container ? container : document.body;
|
|
133
133
|
const textAreaDom = document.createElement("textarea");
|
|
134
|
-
textAreaDom.autocomplete = "off", textAreaDom.
|
|
135
|
-
this.
|
|
136
|
-
this.
|
|
134
|
+
textAreaDom.autocomplete = "off", textAreaDom.innerText = "", this.applyStyle(textAreaDom),
|
|
135
|
+
this.container.append(textAreaDom), this.textAreaDom = textAreaDom, this.isComposing = !1,
|
|
136
|
+
this.composingConfigIdx = -1, this.onInputCbList = [], this.onChangeCbList = [],
|
|
137
137
|
this.onFocusInList = [], this.onFocusOutList = [];
|
|
138
138
|
}
|
|
139
139
|
onInput(cb) {
|
|
@@ -149,7 +149,7 @@ class EditModule {
|
|
|
149
149
|
this.onFocusOutList.push(cb);
|
|
150
150
|
}
|
|
151
151
|
applyStyle(textAreaDom) {
|
|
152
|
-
textAreaDom.setAttribute("style", "width: 100px; height: 30px; left: 0; top: 0; position: absolute; z-index: -1; outline: none; resize: none; border: none; overflow: hidden; color: transparent; user-select: none; caret-color: transparent;background-color: transparent;
|
|
152
|
+
textAreaDom.setAttribute("style", "width: 100px; height: 30px; left: 0; top: 0; position: absolute; z-index: -1; outline: none; resize: none; border: none; overflow: hidden; color: transparent; user-select: none; caret-color: transparent;background-color: transparent;"),
|
|
153
153
|
textAreaDom.addEventListener("input", this.handleInput), textAreaDom.addEventListener("compositionstart", this.handleCompositionStart),
|
|
154
154
|
textAreaDom.addEventListener("compositionend", this.handleCompositionEnd), textAreaDom.addEventListener("focusin", this.handleFocusIn),
|
|
155
155
|
textAreaDom.addEventListener("focusout", this.handleFocusOut), application_1.application.global.addEventListener("keydown", this.handleKeyDown);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/builtin-plugin/edit-module.ts"],"names":[],"mappings":";;;;;;;;;;;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AC,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QAEjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;IACzD,CAAC;IAED,OAAO;QACL,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtF,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAClF,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAClE,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACnE,yBAAW,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACxE,CAAC;CACF;AAlSD,gCAkSC","file":"edit-module.js","sourcesContent":["import { application } from '../../application';\nimport type {\n IRichText,\n IRichTextCharacter,\n IRichTextGraphicAttribute,\n IRichTextParagraphCharacter\n} from '../../interface';\n\n// function getMaxConfigIndexIgnoreLinebreak(textConfig: IRichTextCharacter[]) {\n// let idx = 0;\n// for (let i = 0; i < textConfig.length; i++) {\n// const c = textConfig[i] as IRichTextParagraphCharacter;\n// if (c.text !== '\\n') {\n// idx++;\n// }\n// }\n// return Math.max(idx - 1, 0);\n// }\n\nexport function getDefaultCharacterConfig(attribute: IRichTextGraphicAttribute) {\n const {\n fill = 'black',\n stroke = false,\n fontWeight = 'normal',\n lineHeight,\n fontFamily = 'Arial',\n textAlign\n } = attribute;\n let { fontSize = 12 } = attribute;\n if (!isFinite(fontSize)) {\n fontSize = 12;\n }\n return {\n fill,\n stroke,\n fontSize,\n fontWeight,\n fontFamily,\n lineHeight,\n textAlign\n } as any;\n}\n\n/**\n * 找到cursorIndex所在的textConfig的位置,给出的index就是要插入的准确位置\n * @param textConfig\n * @param cursorIndex\n * @returns\n */\nexport function findConfigIndexByCursorIdx(textConfig: IRichTextCharacter[], cursorIndex: number): number {\n if (cursorIndex < 0) {\n return 0;\n }\n\n // 排序找到对应的元素\n const intCursorIndex = Math.round(cursorIndex);\n let tempCursorIndex = intCursorIndex;\n // 跳过连续换行符中的第一个换行符(但是如果第一个字符就是换行符,那就不跳)\n let lineBreak = (textConfig?.[0] as any)?.text === '\\n';\n let configIdx = 0;\n for (configIdx = 0; configIdx < textConfig.length && tempCursorIndex >= 0; configIdx++) {\n const c = textConfig[configIdx] as IRichTextParagraphCharacter;\n if (c.text === '\\n') {\n tempCursorIndex -= Number(lineBreak);\n lineBreak = true;\n } else {\n tempCursorIndex--;\n lineBreak = false;\n }\n }\n // 说明过限了\n if (tempCursorIndex >= 0) {\n return textConfig.length;\n }\n configIdx -= 1;\n\n // 如果有换行,一定在换行符左边写\n if (cursorIndex > intCursorIndex && !lineBreak) {\n configIdx += 1;\n }\n return configIdx;\n}\n\n/**\n * 根据configIndex找到cursorIndex的位置,忽略单个换行符,连续换行符的时候只忽略第一个\n * @param textConfig\n * @param configIndex\n * @returns\n */\nexport function findCursorIdxByConfigIndex(textConfig: IRichTextCharacter[], configIndex: number): number {\n let cursorIndex = 0;\n if (configIndex < 0) {\n return -0.1;\n }\n // 仅有一个\\n,那不算\n // 如果有连续的\\n,那就少算一个(但是第一个字符是\\n的话,不算)\n let lastLineBreak = (textConfig?.[0] as any)?.text === '\\n';\n\n for (let i = 0; i <= configIndex && i < textConfig.length; i++) {\n const c = textConfig[i] as IRichTextParagraphCharacter;\n if (c.text === '\\n') {\n cursorIndex += Number(lastLineBreak);\n lastLineBreak = true;\n } else {\n cursorIndex++;\n lastLineBreak = false;\n }\n }\n cursorIndex = Math.max(cursorIndex - 1, 0);\n\n // 超出区间了直接设置到尾部,configIndex超过区间,cursorIndex不会超过\n if (configIndex > textConfig.length - 1) {\n // 如果最后一行是一个换行符,那么就得是xx.9否则就是xx.1\n if ((textConfig[textConfig.length - 1] as any)?.text === '\\n') {\n return cursorIndex + 0.9;\n }\n return cursorIndex + 0.1;\n }\n\n // 如果是这个configIdx对应到的是单个换行的话,那么算到下一个字符上\n const lineBreak = (textConfig[configIndex] as any)?.text === '\\n';\n if (configIndex >= textConfig.length - 1 && lineBreak) {\n return cursorIndex + 1 - 0.1;\n }\n const singleLineBreak = lineBreak && (textConfig[configIndex - 1] as any)?.text !== '\\n';\n\n // 光标往左放\n cursorIndex -= 0.1;\n\n // 如果是单行,那么这一个换行符没有算字符,光标要往右放\n if (singleLineBreak) {\n cursorIndex += 0.2;\n }\n return cursorIndex;\n}\n\nexport class EditModule {\n container: HTMLElement;\n textAreaDom: HTMLTextAreaElement;\n currRt: IRichText;\n isComposing: boolean;\n composingConfigIdx: number;\n cursorIndex: number;\n selectionStartCursorIdx: number;\n // 输入的回调(composing的时候每次也会触发)\n onInputCbList: Array<(text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void>;\n // change的回调(composing确认才会触发)\n onChangeCbList: Array<(text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void>;\n onFocusInList: Array<() => void>;\n onFocusOutList: Array<() => void>;\n focusOutTimer: number;\n\n constructor(container?: HTMLElement) {\n this.container = container ?? document.body;\n\n const textAreaDom = document.createElement('textarea');\n textAreaDom.autocomplete = 'off';\n textAreaDom.spellcheck = false;\n textAreaDom.innerText = '';\n this.applyStyle(textAreaDom);\n this.container.append(textAreaDom);\n this.textAreaDom = textAreaDom;\n this.isComposing = false;\n this.composingConfigIdx = -1;\n this.onInputCbList = [];\n this.onChangeCbList = [];\n this.onFocusInList = [];\n this.onFocusOutList = [];\n }\n\n onInput(cb: (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void) {\n this.onInputCbList.push(cb);\n }\n\n onChange(cb: (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void) {\n this.onChangeCbList.push(cb);\n }\n\n onFocusIn(cb: () => void) {\n this.onFocusInList.push(cb);\n }\n\n onFocusOut(cb: () => void) {\n this.onFocusOutList.push(cb);\n }\n\n applyStyle(textAreaDom: HTMLTextAreaElement) {\n textAreaDom.setAttribute(\n 'style',\n `width: 100px; height: 30px; left: 0; top: 0; position: absolute; z-index: -1; outline: none; resize: none; border: none; overflow: hidden; color: transparent; user-select: none; caret-color: transparent;background-color: transparent;opacity: 0;pointer-events: none;`\n );\n\n textAreaDom.addEventListener('input', this.handleInput);\n textAreaDom.addEventListener('compositionstart', this.handleCompositionStart);\n textAreaDom.addEventListener('compositionend', this.handleCompositionEnd);\n // 监听焦点\n textAreaDom.addEventListener('focusin', this.handleFocusIn);\n textAreaDom.addEventListener('focusout', this.handleFocusOut);\n application.global.addEventListener('keydown', this.handleKeyDown);\n }\n\n handleFocusIn = () => {\n // this.focusOutTimer && clearTimeout(this.focusOutTimer);\n // this.focusOutTimer = 0;\n // this.onFocusInList && this.onFocusInList.forEach(cb => cb());\n };\n handleFocusOut = () => {\n // 暂时注释,会导致非期待情况下的误关闭\n // // 延时触发,避免误关闭\n // this.focusOutTimer = setTimeout(() => {\n // this.onFocusOutList && this.onFocusOutList.forEach(cb => cb());\n // }, 100);\n };\n\n handleKeyDown = (e: KeyboardEvent) => {\n if (!this.currRt) {\n return;\n }\n if (e.key === 'Delete' || e.key === 'Backspace') {\n this.handleInput({ data: null, type: 'Backspace' });\n }\n };\n\n handleCompositionStart = () => {\n if (!this.currRt) {\n return;\n }\n this.isComposing = true;\n const { textConfig = [] } = this.currRt.attribute;\n this.composingConfigIdx = this.cursorIndex < 0 ? 0 : findConfigIndexByCursorIdx(textConfig, this.cursorIndex);\n if (this.cursorIndex < 0) {\n const config = textConfig[0];\n textConfig.unshift({ fill: 'black', ...getDefaultCharacterConfig(this.currRt.attribute), ...config, text: '' });\n } else {\n const configIdx = this.composingConfigIdx;\n const lastConfig = textConfig[configIdx] || textConfig[configIdx - 1];\n textConfig.splice(configIdx, 0, {\n fill: 'black',\n ...getDefaultCharacterConfig(this.currRt.attribute),\n ...lastConfig,\n text: ''\n });\n }\n };\n handleCompositionEnd = () => {\n this.isComposing = false;\n\n const text = this.parseCompositionStr(this.composingConfigIdx);\n // 拆分上一次的内容\n // const { textConfig = [] } = this.currRt.attribute;\n // const configIdx = this.composingConfigIdx;\n\n // const lastConfig = textConfig[configIdx];\n // textConfig.splice(configIdx, 1);\n // const text = (lastConfig as any).text;\n // const textList: string[] = text ? Array.from(text.toString()) : [];\n // for (let i = 0; i < textList.length; i++) {\n // textConfig.splice(i + configIdx, 0, { ...lastConfig, isComposing: false, text: textList[i] } as any);\n // }\n // this.currRt.setAttributes({ textConfig });\n // const nextConfigIdx = configIdx + textList.length;\n // this.cursorIndex = findCursorIdxByConfigIndex(textConfig, nextConfigIdx);\n this.composingConfigIdx = -1;\n\n this.onChangeCbList.forEach(cb => {\n cb(\n text,\n this.isComposing,\n // TODO 当换行后刚开始输入会有问题,后续看这里具体Cursor变换逻辑\n this.cursorIndex,\n this.currRt\n );\n });\n };\n\n /**\n * 复合输入以及粘贴,都会复制出一大段内容,这时候需要重新处理textConfig和cursorIndex\n * 1. 拆分text到textConfig\n * 2. 计算新的cursorIndex\n * @param configIdx\n */\n parseCompositionStr(configIdx: number) {\n if (!this.currRt) {\n return '';\n }\n const { textConfig = [] } = this.currRt.attribute;\n\n const lastConfig = textConfig[configIdx] ?? {};\n textConfig.splice(configIdx, 1);\n const text = (lastConfig as any).text;\n const textList: string[] = text ? Array.from(text.toString()) : [];\n for (let i = 0; i < textList.length; i++) {\n textConfig.splice(i + configIdx, 0, {\n fill: 'black',\n ...lastConfig,\n isComposing: false,\n text: textList[i]\n } as any);\n }\n this.currRt.setAttributes({ textConfig });\n const nextConfigIdx = configIdx + textList.length;\n this.cursorIndex = findCursorIdxByConfigIndex(textConfig, nextConfigIdx);\n return text;\n }\n\n handleInput = (ev: any) => {\n if (!this.currRt) {\n return;\n }\n if (ev.inputType === 'historyUndo') {\n return;\n }\n const { textConfig = [], ...rest } = this.currRt.attribute;\n // 删完了,直接返回\n if (ev.type === 'Backspace' && !textConfig.length) {\n return;\n }\n\n let str = (ev as any).data;\n if (!this.isComposing && ev.type !== 'Backspace' && !str) {\n str = '\\n';\n }\n\n // 处理正反选\n if (this.selectionStartCursorIdx > this.cursorIndex) {\n [this.cursorIndex, this.selectionStartCursorIdx] = [this.selectionStartCursorIdx, this.cursorIndex];\n }\n\n const startIdx = findConfigIndexByCursorIdx(textConfig, this.selectionStartCursorIdx);\n const endIdx = findConfigIndexByCursorIdx(textConfig, this.cursorIndex);\n\n // composing的话会插入一个字符,所以往右加一个\n const lastConfigIdx = this.isComposing ? this.composingConfigIdx : Math.max(startIdx - 1, 0);\n // 算一个默认属性\n let lastConfig: any = textConfig[lastConfigIdx];\n if (!lastConfig) {\n lastConfig = getDefaultCharacterConfig(rest);\n }\n let nextConfig = lastConfig;\n\n if (startIdx !== endIdx) {\n textConfig.splice(startIdx, endIdx - startIdx);\n if (this.isComposing) {\n this.composingConfigIdx = startIdx;\n }\n }\n\n let nextConfigIdx = startIdx;\n\n // 删除键\n if (ev.type === 'Backspace' && !this.isComposing) {\n if (startIdx === endIdx) {\n if (startIdx <= 0) {\n return;\n }\n // 删除\n textConfig.splice(startIdx - 1, 1);\n nextConfigIdx = Math.max(startIdx - 1, 0);\n } else {\n // 不插入内容\n }\n } else {\n // 插入\n if (!this.isComposing) {\n nextConfig = { fill: 'black', ...lastConfig, text: '' };\n textConfig.splice(startIdx, 0, nextConfig);\n nextConfigIdx++;\n }\n // 插入\n nextConfig.text = str;\n // 标记isComposing,用来判定是否应该拆分成单个字符\n nextConfig.isComposing = this.isComposing;\n }\n\n this.currRt.setAttributes({ textConfig });\n // 重新计算cursorIdx\n // nextConfigIdx = Math.min(nextConfigIdx, textConfig.length - 1);\n\n let cursorIndex = this.cursorIndex;\n if (str && str.length > 1 && !this.isComposing) {\n // 如果字符长度大于1且不是composing,那说明是粘贴\n // 拆分\n this.parseCompositionStr(nextConfigIdx - 1);\n cursorIndex = this.cursorIndex;\n } else {\n // composing的时候不偏移,只有完整输入后才偏移\n cursorIndex = findCursorIdxByConfigIndex(textConfig, nextConfigIdx);\n if (!this.isComposing) {\n this.cursorIndex = cursorIndex;\n } else {\n this.cursorIndex = this.selectionStartCursorIdx;\n }\n }\n\n if (!this.isComposing) {\n this.onChangeCbList.forEach(cb => {\n cb(str, this.isComposing, cursorIndex, this.currRt);\n });\n } else {\n this.onInputCbList.forEach(cb => {\n cb(str, this.isComposing, cursorIndex, this.currRt);\n });\n }\n };\n\n moveTo(x: number, y: number, rt: IRichText, cursorIndex: number, selectionStartCursorIdx: number) {\n this.textAreaDom.style.left = `${x}px`;\n this.textAreaDom.style.top = `${y}px`;\n setTimeout(() => {\n this.textAreaDom.focus();\n this.textAreaDom.setSelectionRange(0, 0);\n });\n this.currRt = rt;\n\n this.cursorIndex = cursorIndex;\n this.selectionStartCursorIdx = selectionStartCursorIdx;\n }\n\n release() {\n this.textAreaDom.removeEventListener('input', this.handleInput);\n this.textAreaDom.removeEventListener('compositionstart', this.handleCompositionStart);\n this.textAreaDom.removeEventListener('compositionend', this.handleCompositionEnd);\n this.textAreaDom.addEventListener('focusin', this.handleFocusOut);\n this.textAreaDom.addEventListener('focusout', this.handleFocusOut);\n application.global.removeEventListener('keydown', this.handleKeyDown);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/plugins/builtin-plugin/edit-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mDAAgD;AAmBhD,SAAgB,yBAAyB,CAAC,SAAoC;IAC5E,MAAM,EACJ,IAAI,GAAG,OAAO,EACd,MAAM,GAAG,KAAK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C;QAEjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;IACzD,CAAC;IAED,OAAO;QACL,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtF,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAClF,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAClE,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACnE,yBAAW,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACxE,CAAC;CACF;AAjSD,gCAiSC","file":"edit-module.js","sourcesContent":["import { application } from '../../application';\nimport type {\n IRichText,\n IRichTextCharacter,\n IRichTextGraphicAttribute,\n IRichTextParagraphCharacter\n} from '../../interface';\n\n// function getMaxConfigIndexIgnoreLinebreak(textConfig: IRichTextCharacter[]) {\n// let idx = 0;\n// for (let i = 0; i < textConfig.length; i++) {\n// const c = textConfig[i] as IRichTextParagraphCharacter;\n// if (c.text !== '\\n') {\n// idx++;\n// }\n// }\n// return Math.max(idx - 1, 0);\n// }\n\nexport function getDefaultCharacterConfig(attribute: IRichTextGraphicAttribute) {\n const {\n fill = 'black',\n stroke = false,\n fontWeight = 'normal',\n lineHeight,\n fontFamily = 'Arial',\n textAlign\n } = attribute;\n let { fontSize = 12 } = attribute;\n if (!isFinite(fontSize)) {\n fontSize = 12;\n }\n return {\n fill,\n stroke,\n fontSize,\n fontWeight,\n fontFamily,\n lineHeight,\n textAlign\n } as any;\n}\n\n/**\n * 找到cursorIndex所在的textConfig的位置,给出的index就是要插入的准确位置\n * @param textConfig\n * @param cursorIndex\n * @returns\n */\nexport function findConfigIndexByCursorIdx(textConfig: IRichTextCharacter[], cursorIndex: number): number {\n if (cursorIndex < 0) {\n return 0;\n }\n\n // 排序找到对应的元素\n const intCursorIndex = Math.round(cursorIndex);\n let tempCursorIndex = intCursorIndex;\n // 跳过连续换行符中的第一个换行符(但是如果第一个字符就是换行符,那就不跳)\n let lineBreak = (textConfig?.[0] as any)?.text === '\\n';\n let configIdx = 0;\n for (configIdx = 0; configIdx < textConfig.length && tempCursorIndex >= 0; configIdx++) {\n const c = textConfig[configIdx] as IRichTextParagraphCharacter;\n if (c.text === '\\n') {\n tempCursorIndex -= Number(lineBreak);\n lineBreak = true;\n } else {\n tempCursorIndex--;\n lineBreak = false;\n }\n }\n // 说明过限了\n if (tempCursorIndex >= 0) {\n return textConfig.length;\n }\n configIdx -= 1;\n\n // 如果有换行,一定在换行符左边写\n if (cursorIndex > intCursorIndex && !lineBreak) {\n configIdx += 1;\n }\n return configIdx;\n}\n\n/**\n * 根据configIndex找到cursorIndex的位置,忽略单个换行符,连续换行符的时候只忽略第一个\n * @param textConfig\n * @param configIndex\n * @returns\n */\nexport function findCursorIdxByConfigIndex(textConfig: IRichTextCharacter[], configIndex: number): number {\n let cursorIndex = 0;\n if (configIndex < 0) {\n return -0.1;\n }\n // 仅有一个\\n,那不算\n // 如果有连续的\\n,那就少算一个(但是第一个字符是\\n的话,不算)\n let lastLineBreak = (textConfig?.[0] as any)?.text === '\\n';\n\n for (let i = 0; i <= configIndex && i < textConfig.length; i++) {\n const c = textConfig[i] as IRichTextParagraphCharacter;\n if (c.text === '\\n') {\n cursorIndex += Number(lastLineBreak);\n lastLineBreak = true;\n } else {\n cursorIndex++;\n lastLineBreak = false;\n }\n }\n cursorIndex = Math.max(cursorIndex - 1, 0);\n\n // 超出区间了直接设置到尾部,configIndex超过区间,cursorIndex不会超过\n if (configIndex > textConfig.length - 1) {\n // 如果最后一行是一个换行符,那么就得是xx.9否则就是xx.1\n if ((textConfig[textConfig.length - 1] as any)?.text === '\\n') {\n return cursorIndex + 0.9;\n }\n return cursorIndex + 0.1;\n }\n\n // 如果是这个configIdx对应到的是单个换行的话,那么算到下一个字符上\n const lineBreak = (textConfig[configIndex] as any)?.text === '\\n';\n if (configIndex >= textConfig.length - 1 && lineBreak) {\n return cursorIndex + 1 - 0.1;\n }\n const singleLineBreak = lineBreak && (textConfig[configIndex - 1] as any)?.text !== '\\n';\n\n // 光标往左放\n cursorIndex -= 0.1;\n\n // 如果是单行,那么这一个换行符没有算字符,光标要往右放\n if (singleLineBreak) {\n cursorIndex += 0.2;\n }\n return cursorIndex;\n}\n\nexport class EditModule {\n container: HTMLElement;\n textAreaDom: HTMLTextAreaElement;\n currRt: IRichText;\n isComposing: boolean;\n composingConfigIdx: number;\n cursorIndex: number;\n selectionStartCursorIdx: number;\n // 输入的回调(composing的时候每次也会触发)\n onInputCbList: Array<(text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void>;\n // change的回调(composing确认才会触发)\n onChangeCbList: Array<(text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void>;\n onFocusInList: Array<() => void>;\n onFocusOutList: Array<() => void>;\n focusOutTimer: number;\n\n constructor(container?: HTMLElement) {\n this.container = container ?? document.body;\n\n const textAreaDom = document.createElement('textarea');\n textAreaDom.autocomplete = 'off';\n textAreaDom.innerText = '';\n this.applyStyle(textAreaDom);\n this.container.append(textAreaDom);\n this.textAreaDom = textAreaDom;\n this.isComposing = false;\n this.composingConfigIdx = -1;\n this.onInputCbList = [];\n this.onChangeCbList = [];\n this.onFocusInList = [];\n this.onFocusOutList = [];\n }\n\n onInput(cb: (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void) {\n this.onInputCbList.push(cb);\n }\n\n onChange(cb: (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void) {\n this.onChangeCbList.push(cb);\n }\n\n onFocusIn(cb: () => void) {\n this.onFocusInList.push(cb);\n }\n\n onFocusOut(cb: () => void) {\n this.onFocusOutList.push(cb);\n }\n\n applyStyle(textAreaDom: HTMLTextAreaElement) {\n textAreaDom.setAttribute(\n 'style',\n `width: 100px; height: 30px; left: 0; top: 0; position: absolute; z-index: -1; outline: none; resize: none; border: none; overflow: hidden; color: transparent; user-select: none; caret-color: transparent;background-color: transparent;`\n );\n\n textAreaDom.addEventListener('input', this.handleInput);\n textAreaDom.addEventListener('compositionstart', this.handleCompositionStart);\n textAreaDom.addEventListener('compositionend', this.handleCompositionEnd);\n // 监听焦点\n textAreaDom.addEventListener('focusin', this.handleFocusIn);\n textAreaDom.addEventListener('focusout', this.handleFocusOut);\n application.global.addEventListener('keydown', this.handleKeyDown);\n }\n\n handleFocusIn = () => {\n // this.focusOutTimer && clearTimeout(this.focusOutTimer);\n // this.focusOutTimer = 0;\n // this.onFocusInList && this.onFocusInList.forEach(cb => cb());\n };\n handleFocusOut = () => {\n // 暂时注释,会导致非期待情况下的误关闭\n // // 延时触发,避免误关闭\n // this.focusOutTimer = setTimeout(() => {\n // this.onFocusOutList && this.onFocusOutList.forEach(cb => cb());\n // }, 100);\n };\n\n handleKeyDown = (e: KeyboardEvent) => {\n if (!this.currRt) {\n return;\n }\n if (e.key === 'Delete' || e.key === 'Backspace') {\n this.handleInput({ data: null, type: 'Backspace' });\n }\n };\n\n handleCompositionStart = () => {\n if (!this.currRt) {\n return;\n }\n this.isComposing = true;\n const { textConfig = [] } = this.currRt.attribute;\n this.composingConfigIdx = this.cursorIndex < 0 ? 0 : findConfigIndexByCursorIdx(textConfig, this.cursorIndex);\n if (this.cursorIndex < 0) {\n const config = textConfig[0];\n textConfig.unshift({ fill: 'black', ...getDefaultCharacterConfig(this.currRt.attribute), ...config, text: '' });\n } else {\n const configIdx = this.composingConfigIdx;\n const lastConfig = textConfig[configIdx] || textConfig[configIdx - 1];\n textConfig.splice(configIdx, 0, {\n fill: 'black',\n ...getDefaultCharacterConfig(this.currRt.attribute),\n ...lastConfig,\n text: ''\n });\n }\n };\n handleCompositionEnd = () => {\n this.isComposing = false;\n\n const text = this.parseCompositionStr(this.composingConfigIdx);\n // 拆分上一次的内容\n // const { textConfig = [] } = this.currRt.attribute;\n // const configIdx = this.composingConfigIdx;\n\n // const lastConfig = textConfig[configIdx];\n // textConfig.splice(configIdx, 1);\n // const text = (lastConfig as any).text;\n // const textList: string[] = text ? Array.from(text.toString()) : [];\n // for (let i = 0; i < textList.length; i++) {\n // textConfig.splice(i + configIdx, 0, { ...lastConfig, isComposing: false, text: textList[i] } as any);\n // }\n // this.currRt.setAttributes({ textConfig });\n // const nextConfigIdx = configIdx + textList.length;\n // this.cursorIndex = findCursorIdxByConfigIndex(textConfig, nextConfigIdx);\n this.composingConfigIdx = -1;\n\n this.onChangeCbList.forEach(cb => {\n cb(\n text,\n this.isComposing,\n // TODO 当换行后刚开始输入会有问题,后续看这里具体Cursor变换逻辑\n this.cursorIndex,\n this.currRt\n );\n });\n };\n\n /**\n * 复合输入以及粘贴,都会复制出一大段内容,这时候需要重新处理textConfig和cursorIndex\n * 1. 拆分text到textConfig\n * 2. 计算新的cursorIndex\n * @param configIdx\n */\n parseCompositionStr(configIdx: number) {\n if (!this.currRt) {\n return '';\n }\n const { textConfig = [] } = this.currRt.attribute;\n\n const lastConfig = textConfig[configIdx] ?? {};\n textConfig.splice(configIdx, 1);\n const text = (lastConfig as any).text;\n const textList: string[] = text ? Array.from(text.toString()) : [];\n for (let i = 0; i < textList.length; i++) {\n textConfig.splice(i + configIdx, 0, {\n fill: 'black',\n ...lastConfig,\n isComposing: false,\n text: textList[i]\n } as any);\n }\n this.currRt.setAttributes({ textConfig });\n const nextConfigIdx = configIdx + textList.length;\n this.cursorIndex = findCursorIdxByConfigIndex(textConfig, nextConfigIdx);\n return text;\n }\n\n handleInput = (ev: any) => {\n if (!this.currRt) {\n return;\n }\n if (ev.inputType === 'historyUndo') {\n return;\n }\n const { textConfig = [], ...rest } = this.currRt.attribute;\n // 删完了,直接返回\n if (ev.type === 'Backspace' && !textConfig.length) {\n return;\n }\n\n let str = (ev as any).data;\n if (!this.isComposing && ev.type !== 'Backspace' && !str) {\n str = '\\n';\n }\n\n // 处理正反选\n if (this.selectionStartCursorIdx > this.cursorIndex) {\n [this.cursorIndex, this.selectionStartCursorIdx] = [this.selectionStartCursorIdx, this.cursorIndex];\n }\n\n const startIdx = findConfigIndexByCursorIdx(textConfig, this.selectionStartCursorIdx);\n const endIdx = findConfigIndexByCursorIdx(textConfig, this.cursorIndex);\n\n // composing的话会插入一个字符,所以往右加一个\n const lastConfigIdx = this.isComposing ? this.composingConfigIdx : Math.max(startIdx - 1, 0);\n // 算一个默认属性\n let lastConfig: any = textConfig[lastConfigIdx];\n if (!lastConfig) {\n lastConfig = getDefaultCharacterConfig(rest);\n }\n let nextConfig = lastConfig;\n\n if (startIdx !== endIdx) {\n textConfig.splice(startIdx, endIdx - startIdx);\n if (this.isComposing) {\n this.composingConfigIdx = startIdx;\n }\n }\n\n let nextConfigIdx = startIdx;\n\n // 删除键\n if (ev.type === 'Backspace' && !this.isComposing) {\n if (startIdx === endIdx) {\n if (startIdx <= 0) {\n return;\n }\n // 删除\n textConfig.splice(startIdx - 1, 1);\n nextConfigIdx = Math.max(startIdx - 1, 0);\n } else {\n // 不插入内容\n }\n } else {\n // 插入\n if (!this.isComposing) {\n nextConfig = { fill: 'black', ...lastConfig, text: '' };\n textConfig.splice(startIdx, 0, nextConfig);\n nextConfigIdx++;\n }\n // 插入\n nextConfig.text = str;\n // 标记isComposing,用来判定是否应该拆分成单个字符\n nextConfig.isComposing = this.isComposing;\n }\n\n this.currRt.setAttributes({ textConfig });\n // 重新计算cursorIdx\n // nextConfigIdx = Math.min(nextConfigIdx, textConfig.length - 1);\n\n let cursorIndex = this.cursorIndex;\n if (str && str.length > 1 && !this.isComposing) {\n // 如果字符长度大于1且不是composing,那说明是粘贴\n // 拆分\n this.parseCompositionStr(nextConfigIdx - 1);\n cursorIndex = this.cursorIndex;\n } else {\n // composing的时候不偏移,只有完整输入后才偏移\n cursorIndex = findCursorIdxByConfigIndex(textConfig, nextConfigIdx);\n if (!this.isComposing) {\n this.cursorIndex = cursorIndex;\n } else {\n this.cursorIndex = this.selectionStartCursorIdx;\n }\n }\n\n if (!this.isComposing) {\n this.onChangeCbList.forEach(cb => {\n cb(str, this.isComposing, cursorIndex, this.currRt);\n });\n } else {\n this.onInputCbList.forEach(cb => {\n cb(str, this.isComposing, cursorIndex, this.currRt);\n });\n }\n };\n\n moveTo(x: number, y: number, rt: IRichText, cursorIndex: number, selectionStartCursorIdx: number) {\n this.textAreaDom.style.left = `${x}px`;\n this.textAreaDom.style.top = `${y}px`;\n setTimeout(() => {\n this.textAreaDom.focus();\n this.textAreaDom.setSelectionRange(0, 0);\n });\n this.currRt = rt;\n\n this.cursorIndex = cursorIndex;\n this.selectionStartCursorIdx = selectionStartCursorIdx;\n }\n\n release() {\n this.textAreaDom.removeEventListener('input', this.handleInput);\n this.textAreaDom.removeEventListener('compositionstart', this.handleCompositionStart);\n this.textAreaDom.removeEventListener('compositionend', this.handleCompositionEnd);\n this.textAreaDom.addEventListener('focusin', this.handleFocusOut);\n this.textAreaDom.addEventListener('focusout', this.handleFocusOut);\n application.global.removeEventListener('keydown', this.handleKeyDown);\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.registerFlexLayoutPlugin = exports.FlexLayoutPlugin = void 0;
|
|
6
6
|
|
|
7
|
-
const theme_1 = require("../../graphic/theme"), generator_1 = require("../../common/generator"), vutils_1 = require("@visactor/vutils"), factory_1 = require("../../factory"), _tempBounds = new vutils_1.AABBBounds;
|
|
7
|
+
const theme_1 = require("../../graphic/theme"), generator_1 = require("../../common/generator"), vutils_1 = require("@visactor/vutils"), application_1 = require("../../application"), factory_1 = require("../../factory"), _tempBounds = new vutils_1.AABBBounds;
|
|
8
8
|
|
|
9
9
|
class FlexLayoutPlugin {
|
|
10
10
|
constructor() {
|
|
@@ -226,24 +226,21 @@ class FlexLayoutPlugin {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
activate(context) {
|
|
229
|
-
this.pluginService = context
|
|
230
|
-
const stage = this.pluginService.stage;
|
|
231
|
-
stage && (stage.graphicService.hooks.onAttributeUpdate.tap(this.key, (graphic => {
|
|
229
|
+
this.pluginService = context, application_1.application.graphicService.hooks.onAttributeUpdate.tap(this.key, (graphic => {
|
|
232
230
|
graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage && graphic.stage === this.pluginService.stage && this.tryLayout(graphic, !1);
|
|
233
|
-
})),
|
|
231
|
+
})), application_1.application.graphicService.hooks.beforeUpdateAABBBounds.tap(this.key, ((graphic, stage, willUpdate, bounds) => {
|
|
234
232
|
graphic.glyphHost && (graphic = graphic.glyphHost), stage && stage === this.pluginService.stage && graphic.isContainer && !this.skipBoundsTrigger && _tempBounds.copy(bounds);
|
|
235
|
-
})),
|
|
233
|
+
})), application_1.application.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, ((graphic, stage, bounds, params, selfChange) => {
|
|
236
234
|
stage && stage === this.pluginService.stage && graphic.isContainer && !this.skipBoundsTrigger && (_tempBounds.equals(bounds) || this.tryLayout(graphic, !1));
|
|
237
|
-
})),
|
|
235
|
+
})), application_1.application.graphicService.hooks.onSetStage.tap(this.key, (graphic => {
|
|
238
236
|
graphic.glyphHost && (graphic = graphic.glyphHost), this.tryLayout(graphic, !1);
|
|
239
|
-
}))
|
|
237
|
+
}));
|
|
240
238
|
}
|
|
241
239
|
deactivate(context) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
stage.graphicService.hooks.onSetStage.taps = stage.graphicService.hooks.onSetStage.taps.filter((item => item.name !== this.key)));
|
|
240
|
+
application_1.application.graphicService.hooks.onAttributeUpdate.taps = application_1.application.graphicService.hooks.onAttributeUpdate.taps.filter((item => item.name !== this.key)),
|
|
241
|
+
application_1.application.graphicService.hooks.beforeUpdateAABBBounds.taps = application_1.application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
242
|
+
application_1.application.graphicService.hooks.afterUpdateAABBBounds.taps = application_1.application.graphicService.hooks.afterUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
243
|
+
application_1.application.graphicService.hooks.onSetStage.taps = application_1.application.graphicService.hooks.onSetStage.taps.filter((item => item.name !== this.key));
|
|
247
244
|
}
|
|
248
245
|
}
|
|
249
246
|
|