@antv/g 5.0.19 → 5.0.21
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/dist/index.umd.min.js +16 -17
- package/es/Canvas.d.ts +39 -6
- package/es/Canvas.js +61 -23
- package/es/camera/Camera.d.ts +2 -0
- package/es/camera/Camera.js +3 -4
- package/es/css/CSS.d.ts +84 -0
- package/es/css/CSS.js +113 -0
- package/es/css/CSSProperty.d.ts +40 -0
- package/es/css/CSSProperty.js +1 -0
- package/es/css/LayoutRegistry.d.ts +11 -0
- package/es/css/LayoutRegistry.js +22 -0
- package/es/css/StyleValueRegistry.d.ts +113 -0
- package/es/css/StyleValueRegistry.js +887 -0
- package/es/css/cssom/CSSColorValue.d.ts +23 -0
- package/es/css/cssom/CSSColorValue.js +43 -0
- package/es/css/cssom/CSSGradientValue.d.ts +39 -0
- package/es/css/cssom/CSSGradientValue.js +54 -0
- package/es/css/cssom/CSSImageValue.d.ts +1 -0
- package/es/css/cssom/CSSImageValue.js +0 -0
- package/es/css/cssom/CSSKeywordValue.d.ts +15 -0
- package/es/css/cssom/CSSKeywordValue.js +37 -0
- package/es/css/cssom/CSSMathInvert.d.ts +14 -0
- package/es/css/cssom/CSSMathInvert.js +84 -0
- package/es/css/cssom/CSSMathMax.d.ts +17 -0
- package/es/css/cssom/CSSMathMax.js +118 -0
- package/es/css/cssom/CSSMathMin.d.ts +17 -0
- package/es/css/cssom/CSSMathMin.js +119 -0
- package/es/css/cssom/CSSMathNegate.d.ts +14 -0
- package/es/css/cssom/CSSMathNegate.js +80 -0
- package/es/css/cssom/CSSMathOperator.d.ts +11 -0
- package/es/css/cssom/CSSMathOperator.js +32 -0
- package/es/css/cssom/CSSMathProduct.d.ts +16 -0
- package/es/css/cssom/CSSMathProduct.js +109 -0
- package/es/css/cssom/CSSMathSum.d.ts +17 -0
- package/es/css/cssom/CSSMathSum.js +117 -0
- package/es/css/cssom/CSSMathValue.d.ts +11 -0
- package/es/css/cssom/CSSMathValue.js +27 -0
- package/es/css/cssom/CSSMathVariadic.d.ts +9 -0
- package/es/css/cssom/CSSMathVariadic.js +44 -0
- package/es/css/cssom/CSSNumericSumValue.d.ts +7 -0
- package/es/css/cssom/CSSNumericSumValue.js +1 -0
- package/es/css/cssom/CSSNumericValue.d.ts +75 -0
- package/es/css/cssom/CSSNumericValue.js +500 -0
- package/es/css/cssom/CSSNumericValueType.d.ts +33 -0
- package/es/css/cssom/CSSNumericValueType.js +259 -0
- package/es/css/cssom/CSSRGB.d.ts +25 -0
- package/es/css/cssom/CSSRGB.js +48 -0
- package/es/css/cssom/CSSStyleValue.d.ts +53 -0
- package/es/css/cssom/CSSStyleValue.js +625 -0
- package/es/css/cssom/CSSTransformComponent.d.ts +22 -0
- package/es/css/cssom/CSSTransformComponent.js +32 -0
- package/es/css/cssom/CSSTransformValue.d.ts +30 -0
- package/es/css/cssom/CSSTransformValue.js +48 -0
- package/es/css/cssom/CSSTranslate.d.ts +15 -0
- package/es/css/cssom/CSSTranslate.js +44 -0
- package/es/css/cssom/CSSUnitValue.d.ts +33 -0
- package/es/css/cssom/CSSUnitValue.js +252 -0
- package/es/css/cssom/index.d.ts +29 -0
- package/es/css/cssom/index.js +29 -0
- package/es/css/cssom/types.d.ts +86 -0
- package/es/css/cssom/types.js +119 -0
- package/es/css/index.d.ts +10 -0
- package/es/css/index.js +10 -0
- package/es/css/parser/color.d.ts +6 -0
- package/es/{property-handlers → css/parser}/color.js +26 -43
- package/es/css/parser/dimension.d.ts +36 -0
- package/es/css/parser/dimension.js +146 -0
- package/es/css/parser/filter.d.ts +7 -0
- package/es/{property-handlers → css/parser}/filter.js +0 -0
- package/es/css/parser/index.d.ts +15 -0
- package/es/css/parser/index.js +15 -0
- package/es/css/parser/numeric.d.ts +19 -0
- package/es/css/parser/numeric.js +62 -0
- package/es/css/parser/path.d.ts +5 -0
- package/es/{property-handlers → css/parser}/path.js +4 -4
- package/es/{property-handlers → css/parser}/points.d.ts +1 -1
- package/es/{property-handlers → css/parser}/points.js +5 -0
- package/es/css/parser/transform-origin.d.ts +6 -0
- package/es/css/parser/transform-origin.js +45 -0
- package/es/css/parser/transform.d.ts +15 -0
- package/es/{property-handlers → css/parser}/transform.js +16 -139
- package/es/css/parser/types.d.ts +2 -0
- package/es/css/parser/types.js +1 -0
- package/es/css/properties/CSSPropertyAnchor.d.ts +6 -0
- package/es/css/properties/CSSPropertyAnchor.js +24 -0
- package/es/{property-handlers/clipPath.d.ts → css/properties/CSSPropertyClipPath.d.ts} +4 -2
- package/es/css/properties/CSSPropertyClipPath.js +50 -0
- package/es/css/properties/CSSPropertyColor.d.ts +13 -0
- package/es/css/properties/CSSPropertyColor.js +30 -0
- package/es/css/properties/CSSPropertyFilter.d.ts +5 -0
- package/es/css/properties/CSSPropertyFilter.js +16 -0
- package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +19 -0
- package/es/css/properties/CSSPropertyLengthOrPercentage.js +74 -0
- package/es/css/properties/CSSPropertyLineDash.d.ts +7 -0
- package/es/css/properties/CSSPropertyLineDash.js +25 -0
- package/es/css/properties/CSSPropertyLocalPosition.d.ts +20 -0
- package/es/css/properties/CSSPropertyLocalPosition.js +46 -0
- package/es/css/properties/CSSPropertyOffsetDistance.d.ts +7 -0
- package/es/css/properties/CSSPropertyOffsetDistance.js +33 -0
- package/es/css/properties/CSSPropertyOffsetPath.d.ts +4 -0
- package/es/css/properties/CSSPropertyOffsetPath.js +31 -0
- package/es/css/properties/CSSPropertyOpacity.d.ts +9 -0
- package/es/css/properties/CSSPropertyOpacity.js +20 -0
- package/es/css/properties/CSSPropertyPath.d.ts +14 -0
- package/es/css/properties/CSSPropertyPath.js +51 -0
- package/es/css/properties/CSSPropertyPoints.d.ts +17 -0
- package/es/css/properties/CSSPropertyPoints.js +28 -0
- package/es/css/properties/CSSPropertyShadowBlur.d.ts +4 -0
- package/es/css/properties/CSSPropertyShadowBlur.js +22 -0
- package/es/css/properties/CSSPropertyText.d.ts +6 -0
- package/es/css/properties/CSSPropertyText.js +30 -0
- package/es/css/properties/CSSPropertyTextTransform.d.ts +4 -0
- package/es/css/properties/CSSPropertyTextTransform.js +29 -0
- package/es/{property-handlers/transform.d.ts → css/properties/CSSPropertyTransform.d.ts} +7 -15
- package/es/css/properties/CSSPropertyTransform.js +157 -0
- package/es/css/properties/CSSPropertyTransformOrigin.d.ts +10 -0
- package/es/css/properties/CSSPropertyTransformOrigin.js +21 -0
- package/es/css/properties/CSSPropertyVisibility.d.ts +11 -0
- package/es/css/properties/CSSPropertyVisibility.js +24 -0
- package/es/css/properties/CSSPropertyZIndex.d.ts +6 -0
- package/es/css/properties/CSSPropertyZIndex.js +33 -0
- package/es/css/properties/index.d.ts +18 -0
- package/es/css/properties/index.js +18 -0
- package/es/display-objects/Circle.d.ts +3 -4
- package/es/display-objects/Circle.js +3 -2
- package/es/display-objects/DisplayObject.d.ts +27 -10
- package/es/display-objects/DisplayObject.js +125 -148
- package/es/display-objects/Ellipse.d.ts +5 -7
- package/es/display-objects/Ellipse.js +4 -3
- package/es/display-objects/Group.d.ts +14 -11
- package/es/display-objects/Group.js +12 -4
- package/es/display-objects/HTML.d.ts +3 -3
- package/es/display-objects/Image.d.ts +3 -5
- package/es/display-objects/Image.js +3 -3
- package/es/display-objects/Line.d.ts +7 -6
- package/es/display-objects/Line.js +3 -5
- package/es/display-objects/Path.d.ts +2 -2
- package/es/display-objects/Path.js +1 -3
- package/es/display-objects/Polyline.js +1 -3
- package/es/display-objects/Rect.d.ts +5 -7
- package/es/display-objects/Rect.js +4 -3
- package/es/display-objects/Text.d.ts +15 -19
- package/es/display-objects/Text.js +13 -14
- package/es/dom/AnimationTimeline.d.ts +3 -0
- package/es/dom/AnimationTimeline.js +5 -5
- package/es/dom/Document.d.ts +12 -0
- package/es/dom/Document.js +133 -11
- package/es/dom/Element.d.ts +6 -1
- package/es/dom/Element.js +13 -3
- package/es/dom/FederatedEvent.d.ts +1 -5
- package/es/dom/FederatedEvent.js +0 -10
- package/es/dom/MutationObserver.d.ts +0 -1
- package/es/dom/MutationObserver.js +6 -3
- package/es/dom/interfaces.d.ts +14 -2
- package/es/dom/interfaces.js +1 -0
- package/es/global-module.d.ts +0 -8
- package/es/global-module.js +25 -71
- package/es/index.d.ts +4 -5
- package/es/index.js +9 -10
- package/es/plugins/CullingPlugin.js +2 -2
- package/es/plugins/DirtyCheckPlugin.d.ts +0 -1
- package/es/plugins/DirtyCheckPlugin.js +5 -8
- package/es/plugins/EventPlugin.d.ts +1 -0
- package/es/plugins/EventPlugin.js +71 -19
- package/es/plugins/PrepareRendererPlugin.d.ts +1 -0
- package/es/plugins/PrepareRendererPlugin.js +13 -19
- package/es/services/EventService.d.ts +1 -0
- package/es/services/EventService.js +37 -20
- package/es/services/OffscreenCanvasCreator.d.ts +13 -0
- package/es/services/{text/OffscreenCanvasCreator.js → OffscreenCanvasCreator.js} +23 -12
- package/es/services/RenderingService.d.ts +35 -2
- package/es/services/RenderingService.js +52 -11
- package/es/services/SceneGraphSelector.d.ts +3 -1
- package/es/services/SceneGraphSelector.js +43 -12
- package/es/services/SceneGraphService.d.ts +5 -0
- package/es/services/SceneGraphService.js +13 -10
- package/es/services/{text/index.d.ts → TextService.d.ts} +5 -4
- package/es/services/{text/index.js → TextService.js} +35 -39
- package/es/services/aabb/CircleUpdater.js +6 -17
- package/es/services/aabb/EllipseUpdater.js +6 -23
- package/es/services/aabb/LineUpdater.js +4 -4
- package/es/services/aabb/RectUpdater.d.ts +2 -2
- package/es/services/aabb/RectUpdater.js +21 -16
- package/es/services/aabb/TextUpdater.d.ts +3 -1
- package/es/services/aabb/TextUpdater.js +63 -25
- package/es/services/index.d.ts +2 -2
- package/es/services/index.js +2 -2
- package/es/shapes/index.d.ts +0 -1
- package/es/shapes/index.js +1 -2
- package/es/types.d.ts +62 -27
- package/es/utils/animation.js +1 -1
- package/es/utils/assert.d.ts +3 -0
- package/es/utils/assert.js +15 -0
- package/es/utils/event.d.ts +41 -9
- package/es/utils/event.js +2 -65
- package/es/utils/index.d.ts +1 -1
- package/es/utils/index.js +1 -1
- package/es/utils/interpolation.js +39 -37
- package/es/utils/math.d.ts +5 -0
- package/es/utils/math.js +54 -0
- package/es/utils/path.d.ts +1 -1
- package/es/utils/path.js +27 -29
- package/es/utils/text.js +3 -7
- package/lib/Canvas.d.ts +39 -6
- package/lib/Canvas.js +64 -27
- package/lib/camera/Camera.d.ts +2 -0
- package/lib/camera/Camera.js +3 -5
- package/lib/css/CSS.d.ts +84 -0
- package/lib/css/CSS.js +125 -0
- package/lib/css/CSSProperty.d.ts +40 -0
- package/lib/css/CSSProperty.js +5 -0
- package/lib/css/LayoutRegistry.d.ts +11 -0
- package/lib/css/LayoutRegistry.js +30 -0
- package/lib/css/StyleValueRegistry.d.ts +113 -0
- package/lib/css/StyleValueRegistry.js +903 -0
- package/lib/css/cssom/CSSColorValue.d.ts +23 -0
- package/lib/css/cssom/CSSColorValue.js +51 -0
- package/lib/css/cssom/CSSGradientValue.d.ts +39 -0
- package/lib/css/cssom/CSSGradientValue.js +64 -0
- package/lib/css/cssom/CSSImageValue.d.ts +1 -0
- package/lib/css/cssom/CSSImageValue.js +1 -0
- package/lib/css/cssom/CSSKeywordValue.d.ts +15 -0
- package/lib/css/cssom/CSSKeywordValue.js +45 -0
- package/lib/css/cssom/CSSMathInvert.d.ts +14 -0
- package/lib/css/cssom/CSSMathInvert.js +94 -0
- package/lib/css/cssom/CSSMathMax.d.ts +17 -0
- package/lib/css/cssom/CSSMathMax.js +128 -0
- package/lib/css/cssom/CSSMathMin.d.ts +17 -0
- package/lib/css/cssom/CSSMathMin.js +128 -0
- package/lib/css/cssom/CSSMathNegate.d.ts +14 -0
- package/lib/css/cssom/CSSMathNegate.js +89 -0
- package/lib/css/cssom/CSSMathOperator.d.ts +11 -0
- package/lib/css/cssom/CSSMathOperator.js +40 -0
- package/lib/css/cssom/CSSMathProduct.d.ts +16 -0
- package/lib/css/cssom/CSSMathProduct.js +119 -0
- package/lib/css/cssom/CSSMathSum.d.ts +17 -0
- package/lib/css/cssom/CSSMathSum.js +129 -0
- package/lib/css/cssom/CSSMathValue.d.ts +11 -0
- package/lib/css/cssom/CSSMathValue.js +35 -0
- package/lib/css/cssom/CSSMathVariadic.d.ts +9 -0
- package/lib/css/cssom/CSSMathVariadic.js +55 -0
- package/lib/css/cssom/CSSNumericSumValue.d.ts +7 -0
- package/lib/css/cssom/CSSNumericSumValue.js +5 -0
- package/lib/css/cssom/CSSNumericValue.d.ts +75 -0
- package/lib/css/cssom/CSSNumericValue.js +511 -0
- package/lib/css/cssom/CSSNumericValueType.d.ts +33 -0
- package/lib/css/cssom/CSSNumericValueType.js +272 -0
- package/lib/css/cssom/CSSRGB.d.ts +25 -0
- package/lib/css/cssom/CSSRGB.js +56 -0
- package/lib/css/cssom/CSSStyleValue.d.ts +53 -0
- package/lib/css/cssom/CSSStyleValue.js +634 -0
- package/lib/css/cssom/CSSTransformComponent.d.ts +22 -0
- package/lib/css/cssom/CSSTransformComponent.js +39 -0
- package/lib/css/cssom/CSSTransformValue.d.ts +30 -0
- package/lib/css/cssom/CSSTransformValue.js +56 -0
- package/lib/css/cssom/CSSTranslate.d.ts +15 -0
- package/lib/css/cssom/CSSTranslate.js +53 -0
- package/lib/css/cssom/CSSUnitValue.d.ts +33 -0
- package/lib/css/cssom/CSSUnitValue.js +267 -0
- package/lib/css/cssom/index.d.ts +29 -0
- package/lib/css/cssom/index.js +278 -0
- package/lib/css/cssom/types.d.ts +86 -0
- package/lib/css/cssom/types.js +130 -0
- package/lib/css/index.d.ts +10 -0
- package/lib/css/index.js +96 -0
- package/lib/css/parser/color.d.ts +6 -0
- package/lib/{property-handlers → css/parser}/color.js +25 -44
- package/lib/css/parser/dimension.d.ts +36 -0
- package/lib/css/parser/dimension.js +173 -0
- package/lib/css/parser/filter.d.ts +7 -0
- package/lib/{property-handlers → css/parser}/filter.js +0 -0
- package/lib/css/parser/index.d.ts +15 -0
- package/lib/css/parser/index.js +122 -0
- package/lib/css/parser/numeric.d.ts +19 -0
- package/lib/css/parser/numeric.js +81 -0
- package/lib/css/parser/path.d.ts +5 -0
- package/lib/{property-handlers → css/parser}/path.js +4 -4
- package/lib/{property-handlers → css/parser}/points.d.ts +1 -1
- package/lib/{property-handlers → css/parser}/points.js +6 -0
- package/lib/css/parser/transform-origin.d.ts +6 -0
- package/lib/css/parser/transform-origin.js +52 -0
- package/lib/css/parser/transform.d.ts +15 -0
- package/lib/{property-handlers → css/parser}/transform.js +22 -146
- package/lib/css/parser/types.d.ts +2 -0
- package/lib/css/parser/types.js +5 -0
- package/lib/css/properties/CSSPropertyAnchor.d.ts +6 -0
- package/lib/css/properties/CSSPropertyAnchor.js +33 -0
- package/lib/{property-handlers/clipPath.d.ts → css/properties/CSSPropertyClipPath.d.ts} +4 -2
- package/lib/css/properties/CSSPropertyClipPath.js +59 -0
- package/lib/css/properties/CSSPropertyColor.d.ts +13 -0
- package/lib/css/properties/CSSPropertyColor.js +40 -0
- package/lib/css/properties/CSSPropertyFilter.d.ts +5 -0
- package/lib/css/properties/CSSPropertyFilter.js +25 -0
- package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +19 -0
- package/lib/css/properties/CSSPropertyLengthOrPercentage.js +83 -0
- package/lib/css/properties/CSSPropertyLineDash.d.ts +7 -0
- package/lib/css/properties/CSSPropertyLineDash.js +34 -0
- package/lib/css/properties/CSSPropertyLocalPosition.d.ts +20 -0
- package/lib/css/properties/CSSPropertyLocalPosition.js +56 -0
- package/lib/css/properties/CSSPropertyOffsetDistance.d.ts +7 -0
- package/lib/css/properties/CSSPropertyOffsetDistance.js +42 -0
- package/lib/css/properties/CSSPropertyOffsetPath.d.ts +4 -0
- package/lib/css/properties/CSSPropertyOffsetPath.js +39 -0
- package/lib/css/properties/CSSPropertyOpacity.d.ts +9 -0
- package/lib/css/properties/CSSPropertyOpacity.js +29 -0
- package/lib/css/properties/CSSPropertyPath.d.ts +14 -0
- package/lib/css/properties/CSSPropertyPath.js +60 -0
- package/lib/css/properties/CSSPropertyPoints.d.ts +17 -0
- package/lib/css/properties/CSSPropertyPoints.js +37 -0
- package/lib/css/properties/CSSPropertyShadowBlur.d.ts +4 -0
- package/lib/css/properties/CSSPropertyShadowBlur.js +32 -0
- package/lib/css/properties/CSSPropertyText.d.ts +6 -0
- package/lib/css/properties/CSSPropertyText.js +39 -0
- package/lib/css/properties/CSSPropertyTextTransform.d.ts +4 -0
- package/lib/css/properties/CSSPropertyTextTransform.js +38 -0
- package/lib/{property-handlers/transform.d.ts → css/properties/CSSPropertyTransform.d.ts} +7 -15
- package/lib/css/properties/CSSPropertyTransform.js +168 -0
- package/lib/css/properties/CSSPropertyTransformOrigin.d.ts +10 -0
- package/lib/css/properties/CSSPropertyTransformOrigin.js +30 -0
- package/lib/css/properties/CSSPropertyVisibility.d.ts +11 -0
- package/lib/css/properties/CSSPropertyVisibility.js +32 -0
- package/lib/css/properties/CSSPropertyZIndex.d.ts +6 -0
- package/lib/css/properties/CSSPropertyZIndex.js +42 -0
- package/lib/css/properties/index.d.ts +18 -0
- package/lib/css/properties/index.js +239 -0
- package/lib/display-objects/Circle.d.ts +3 -4
- package/lib/display-objects/Circle.js +3 -2
- package/lib/display-objects/DisplayObject.d.ts +27 -10
- package/lib/display-objects/DisplayObject.js +127 -148
- package/lib/display-objects/Ellipse.d.ts +5 -7
- package/lib/display-objects/Ellipse.js +4 -3
- package/lib/display-objects/Group.d.ts +14 -11
- package/lib/display-objects/Group.js +12 -4
- package/lib/display-objects/HTML.d.ts +3 -3
- package/lib/display-objects/Image.d.ts +3 -5
- package/lib/display-objects/Image.js +3 -3
- package/lib/display-objects/Line.d.ts +7 -6
- package/lib/display-objects/Line.js +2 -4
- package/lib/display-objects/Path.d.ts +2 -2
- package/lib/display-objects/Path.js +0 -2
- package/lib/display-objects/Polyline.js +0 -2
- package/lib/display-objects/Rect.d.ts +5 -7
- package/lib/display-objects/Rect.js +4 -3
- package/lib/display-objects/Text.d.ts +15 -19
- package/lib/display-objects/Text.js +12 -13
- package/lib/dom/AnimationTimeline.d.ts +3 -0
- package/lib/dom/AnimationTimeline.js +5 -6
- package/lib/dom/Document.d.ts +12 -0
- package/lib/dom/Document.js +134 -10
- package/lib/dom/Element.d.ts +6 -1
- package/lib/dom/Element.js +14 -4
- package/lib/dom/FederatedEvent.d.ts +1 -5
- package/lib/dom/FederatedEvent.js +0 -10
- package/lib/dom/MutationObserver.d.ts +0 -1
- package/lib/dom/MutationObserver.js +6 -4
- package/lib/dom/interfaces.d.ts +14 -2
- package/lib/dom/interfaces.js +1 -0
- package/lib/global-module.d.ts +0 -8
- package/lib/global-module.js +42 -104
- package/lib/index.d.ts +4 -5
- package/lib/index.js +41 -54
- package/lib/plugins/CullingPlugin.js +2 -2
- package/lib/plugins/DirtyCheckPlugin.d.ts +0 -1
- package/lib/plugins/DirtyCheckPlugin.js +5 -8
- package/lib/plugins/EventPlugin.d.ts +1 -0
- package/lib/plugins/EventPlugin.js +71 -18
- package/lib/plugins/PrepareRendererPlugin.d.ts +1 -0
- package/lib/plugins/PrepareRendererPlugin.js +10 -20
- package/lib/services/EventService.d.ts +1 -0
- package/lib/services/EventService.js +38 -21
- package/lib/services/OffscreenCanvasCreator.d.ts +13 -0
- package/lib/services/{text/OffscreenCanvasCreator.js → OffscreenCanvasCreator.js} +23 -12
- package/lib/services/RenderingService.d.ts +35 -2
- package/lib/services/RenderingService.js +52 -11
- package/lib/services/SceneGraphSelector.d.ts +3 -1
- package/lib/services/SceneGraphSelector.js +45 -15
- package/lib/services/SceneGraphService.d.ts +5 -0
- package/lib/services/SceneGraphService.js +13 -10
- package/lib/services/{text/index.d.ts → TextService.d.ts} +5 -4
- package/lib/services/{text/index.js → TextService.js} +36 -41
- package/lib/services/aabb/CircleUpdater.js +6 -17
- package/lib/services/aabb/EllipseUpdater.js +6 -23
- package/lib/services/aabb/LineUpdater.js +4 -4
- package/lib/services/aabb/RectUpdater.d.ts +2 -2
- package/lib/services/aabb/RectUpdater.js +22 -16
- package/lib/services/aabb/TextUpdater.d.ts +3 -1
- package/lib/services/aabb/TextUpdater.js +65 -26
- package/lib/services/index.d.ts +2 -2
- package/lib/services/index.js +8 -8
- package/lib/shapes/index.d.ts +0 -1
- package/lib/shapes/index.js +0 -13
- package/lib/types.d.ts +62 -27
- package/lib/utils/animation.js +1 -1
- package/lib/utils/assert.d.ts +3 -0
- package/lib/utils/assert.js +26 -0
- package/lib/utils/event.d.ts +41 -9
- package/lib/utils/event.js +2 -76
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +13 -13
- package/lib/utils/interpolation.js +35 -30
- package/lib/utils/math.d.ts +5 -0
- package/lib/utils/math.js +64 -0
- package/lib/utils/path.d.ts +1 -1
- package/lib/utils/path.js +27 -29
- package/lib/utils/text.js +2 -6
- package/package.json +3 -4
- package/es/property-handlers/aabb.d.ts +0 -2
- package/es/property-handlers/aabb.js +0 -134
- package/es/property-handlers/anchor.d.ts +0 -4
- package/es/property-handlers/anchor.js +0 -21
- package/es/property-handlers/clipPath.js +0 -36
- package/es/property-handlers/color.d.ts +0 -34
- package/es/property-handlers/dimension.d.ts +0 -31
- package/es/property-handlers/dimension.js +0 -192
- package/es/property-handlers/filter.d.ts +0 -8
- package/es/property-handlers/index.d.ts +0 -21
- package/es/property-handlers/index.js +0 -21
- package/es/property-handlers/inherit.d.ts +0 -6
- package/es/property-handlers/inherit.js +0 -25
- package/es/property-handlers/interfaces.d.ts +0 -20
- package/es/property-handlers/interfaces.js +0 -6
- package/es/property-handlers/lineDash.d.ts +0 -6
- package/es/property-handlers/lineDash.js +0 -27
- package/es/property-handlers/localPosition.d.ts +0 -2
- package/es/property-handlers/localPosition.js +0 -11
- package/es/property-handlers/numeric.d.ts +0 -5
- package/es/property-handlers/numeric.js +0 -34
- package/es/property-handlers/offsetDistance.d.ts +0 -5
- package/es/property-handlers/offsetDistance.js +0 -20
- package/es/property-handlers/offsetPath.d.ts +0 -5
- package/es/property-handlers/offsetPath.js +0 -18
- package/es/property-handlers/origin.d.ts +0 -11
- package/es/property-handlers/origin.js +0 -68
- package/es/property-handlers/path.d.ts +0 -4
- package/es/property-handlers/text.d.ts +0 -2
- package/es/property-handlers/text.js +0 -3
- package/es/property-handlers/textTransform.d.ts +0 -6
- package/es/property-handlers/textTransform.js +0 -19
- package/es/property-handlers/zIndex.d.ts +0 -2
- package/es/property-handlers/zIndex.js +0 -16
- package/es/services/text/OffscreenCanvasCreator.d.ts +0 -6
- package/es/shapes/Polygon.d.ts +0 -9
- package/es/shapes/Polygon.js +0 -64
- package/es/shapes/Rect.d.ts +0 -12
- package/es/shapes/Rect.js +0 -24
- package/es/utils/raf.d.ts +0 -6
- package/es/utils/raf.js +0 -13
- package/lib/property-handlers/aabb.d.ts +0 -2
- package/lib/property-handlers/aabb.js +0 -150
- package/lib/property-handlers/anchor.d.ts +0 -4
- package/lib/property-handlers/anchor.js +0 -34
- package/lib/property-handlers/clipPath.js +0 -43
- package/lib/property-handlers/color.d.ts +0 -34
- package/lib/property-handlers/dimension.d.ts +0 -31
- package/lib/property-handlers/dimension.js +0 -217
- package/lib/property-handlers/filter.d.ts +0 -8
- package/lib/property-handlers/index.d.ts +0 -21
- package/lib/property-handlers/index.js +0 -265
- package/lib/property-handlers/inherit.d.ts +0 -6
- package/lib/property-handlers/inherit.js +0 -34
- package/lib/property-handlers/interfaces.d.ts +0 -20
- package/lib/property-handlers/interfaces.js +0 -18
- package/lib/property-handlers/lineDash.d.ts +0 -6
- package/lib/property-handlers/lineDash.js +0 -36
- package/lib/property-handlers/localPosition.d.ts +0 -2
- package/lib/property-handlers/localPosition.js +0 -18
- package/lib/property-handlers/numeric.d.ts +0 -5
- package/lib/property-handlers/numeric.js +0 -50
- package/lib/property-handlers/offsetDistance.d.ts +0 -5
- package/lib/property-handlers/offsetDistance.js +0 -27
- package/lib/property-handlers/offsetPath.d.ts +0 -5
- package/lib/property-handlers/offsetPath.js +0 -25
- package/lib/property-handlers/origin.d.ts +0 -11
- package/lib/property-handlers/origin.js +0 -79
- package/lib/property-handlers/path.d.ts +0 -4
- package/lib/property-handlers/text.d.ts +0 -2
- package/lib/property-handlers/text.js +0 -10
- package/lib/property-handlers/textTransform.d.ts +0 -6
- package/lib/property-handlers/textTransform.js +0 -27
- package/lib/property-handlers/zIndex.d.ts +0 -2
- package/lib/property-handlers/zIndex.js +0 -23
- package/lib/services/text/OffscreenCanvasCreator.d.ts +0 -6
- package/lib/shapes/Polygon.d.ts +0 -9
- package/lib/shapes/Polygon.js +0 -71
- package/lib/shapes/Rect.d.ts +0 -12
- package/lib/shapes/Rect.js +0 -31
- package/lib/utils/raf.d.ts +0 -6
- package/lib/utils/raf.js +0 -26
|
@@ -9,6 +9,8 @@ var _tslib = require("tslib");
|
|
|
9
9
|
|
|
10
10
|
var _manaSyringe = require("mana-syringe");
|
|
11
11
|
|
|
12
|
+
var _util = require("@antv/util");
|
|
13
|
+
|
|
12
14
|
var _FederatedPointerEvent = require("../dom/FederatedPointerEvent");
|
|
13
15
|
|
|
14
16
|
var _FederatedWheelEvent = require("../dom/FederatedWheelEvent");
|
|
@@ -42,14 +44,16 @@ function () {
|
|
|
42
44
|
|
|
43
45
|
var _b, _c;
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
var canvas = (_c = (_b = _this.renderingContext.root) === null || _b === void 0 ? void 0 : _b.ownerDocument) === null || _c === void 0 ? void 0 : _c.defaultView;
|
|
48
|
+
if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') return;
|
|
49
|
+
|
|
50
|
+
var normalizedEvents = _this.normalizeToPointerEvent(nativeEvent, canvas);
|
|
47
51
|
|
|
48
52
|
try {
|
|
49
53
|
for (var normalizedEvents_1 = (0, _tslib.__values)(normalizedEvents), normalizedEvents_1_1 = normalizedEvents_1.next(); !normalizedEvents_1_1.done; normalizedEvents_1_1 = normalizedEvents_1.next()) {
|
|
50
54
|
var normalizedEvent = normalizedEvents_1_1.value;
|
|
51
55
|
|
|
52
|
-
var event_1 = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent,
|
|
56
|
+
var event_1 = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent, canvas);
|
|
53
57
|
|
|
54
58
|
_this.eventService.mapEvent(event_1);
|
|
55
59
|
}
|
|
@@ -74,6 +78,7 @@ function () {
|
|
|
74
78
|
EventPlugin.prototype.apply = function (renderingService) {
|
|
75
79
|
var _this = this;
|
|
76
80
|
|
|
81
|
+
var canvas = this.renderingContext.root.ownerDocument.defaultView;
|
|
77
82
|
this.eventService.setPickHandler(function (position) {
|
|
78
83
|
return (0, _tslib.__awaiter)(_this, void 0, void 0, function () {
|
|
79
84
|
var picked;
|
|
@@ -84,14 +89,16 @@ function () {
|
|
|
84
89
|
/*yield*/
|
|
85
90
|
, this.renderingService.hooks.pick.promise({
|
|
86
91
|
position: position,
|
|
87
|
-
picked:
|
|
92
|
+
picked: [],
|
|
93
|
+
topmost: true // we only concern the topmost element
|
|
94
|
+
|
|
88
95
|
})];
|
|
89
96
|
|
|
90
97
|
case 1:
|
|
91
98
|
picked = _a.sent().picked;
|
|
92
99
|
return [2
|
|
93
100
|
/*return*/
|
|
94
|
-
, picked];
|
|
101
|
+
, picked[0] || null];
|
|
95
102
|
}
|
|
96
103
|
});
|
|
97
104
|
});
|
|
@@ -104,13 +111,11 @@ function () {
|
|
|
104
111
|
renderingService.hooks.pointerDown.tap(EventPlugin_1.tag, function (nativeEvent) {
|
|
105
112
|
var e_2, _a;
|
|
106
113
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (_event.supportsTouchEvents && nativeEvent.pointerType === 'touch') {
|
|
114
|
+
if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') {
|
|
110
115
|
return;
|
|
111
116
|
}
|
|
112
117
|
|
|
113
|
-
var events =
|
|
118
|
+
var events = _this.normalizeToPointerEvent(nativeEvent, canvas);
|
|
114
119
|
|
|
115
120
|
if (_this.autoPreventDefault && events[0].isNormalized) {
|
|
116
121
|
var cancelable = nativeEvent.cancelable || !('cancelable' in nativeEvent);
|
|
@@ -124,7 +129,7 @@ function () {
|
|
|
124
129
|
for (var events_1 = (0, _tslib.__values)(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) {
|
|
125
130
|
var event_2 = events_1_1.value;
|
|
126
131
|
|
|
127
|
-
var federatedEvent = _this.bootstrapEvent(_this.rootPointerEvent, event_2,
|
|
132
|
+
var federatedEvent = _this.bootstrapEvent(_this.rootPointerEvent, event_2, canvas);
|
|
128
133
|
|
|
129
134
|
_this.eventService.mapEvent(federatedEvent);
|
|
130
135
|
}
|
|
@@ -145,22 +150,21 @@ function () {
|
|
|
145
150
|
renderingService.hooks.pointerUp.tap(EventPlugin_1.tag, function (nativeEvent) {
|
|
146
151
|
var e_3, _a;
|
|
147
152
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (_event.supportsTouchEvents && nativeEvent.pointerType === 'touch') return; // account for element in SVG
|
|
153
|
+
if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') return; // account for element in SVG
|
|
151
154
|
|
|
152
155
|
var $element = _this.contextService.getDomElement();
|
|
153
156
|
|
|
154
157
|
var outside = $element && nativeEvent.target && nativeEvent.target !== $element && // @ts-ignore
|
|
155
158
|
$element.contains && // @ts-ignore
|
|
156
159
|
!$element.contains(nativeEvent.target) ? 'outside' : '';
|
|
157
|
-
|
|
160
|
+
|
|
161
|
+
var normalizedEvents = _this.normalizeToPointerEvent(nativeEvent, canvas);
|
|
158
162
|
|
|
159
163
|
try {
|
|
160
164
|
for (var normalizedEvents_2 = (0, _tslib.__values)(normalizedEvents), normalizedEvents_2_1 = normalizedEvents_2.next(); !normalizedEvents_2_1.done; normalizedEvents_2_1 = normalizedEvents_2.next()) {
|
|
161
165
|
var normalizedEvent = normalizedEvents_2_1.value;
|
|
162
166
|
|
|
163
|
-
var event_3 = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent,
|
|
167
|
+
var event_3 = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent, canvas);
|
|
164
168
|
|
|
165
169
|
event_3.type += outside;
|
|
166
170
|
|
|
@@ -186,9 +190,8 @@ function () {
|
|
|
186
190
|
};
|
|
187
191
|
|
|
188
192
|
EventPlugin.prototype.bootstrapEvent = function (event, nativeEvent, view) {
|
|
189
|
-
event.view = view;
|
|
190
|
-
|
|
191
|
-
event._originalEvent = null;
|
|
193
|
+
event.view = view;
|
|
194
|
+
event.originalEvent = null;
|
|
192
195
|
event.nativeEvent = nativeEvent;
|
|
193
196
|
event.pointerId = nativeEvent.pointerId;
|
|
194
197
|
event.width = nativeEvent.width;
|
|
@@ -290,6 +293,56 @@ function () {
|
|
|
290
293
|
this.contextService.applyCursorStyle(cursor || this.canvasConfig.cursor || 'default');
|
|
291
294
|
};
|
|
292
295
|
|
|
296
|
+
EventPlugin.prototype.normalizeToPointerEvent = function (event, canvas) {
|
|
297
|
+
var normalizedEvents = [];
|
|
298
|
+
|
|
299
|
+
if (canvas.isTouchEvent(event)) {
|
|
300
|
+
for (var i = 0; i < event.changedTouches.length; i++) {
|
|
301
|
+
var touch = event.changedTouches[i]; // use changedTouches instead of touches since touchend has no touches
|
|
302
|
+
// @see https://stackoverflow.com/a/10079076
|
|
303
|
+
|
|
304
|
+
if ((0, _util.isUndefined)(touch.button)) touch.button = event.touches.length ? 1 : 0;
|
|
305
|
+
if ((0, _util.isUndefined)(touch.buttons)) touch.buttons = event.touches.length ? 1 : 0;
|
|
306
|
+
|
|
307
|
+
if ((0, _util.isUndefined)(touch.isPrimary)) {
|
|
308
|
+
touch.isPrimary = event.touches.length === 1 && event.type === 'touchstart';
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if ((0, _util.isUndefined)(touch.width)) touch.width = touch.radiusX || 1;
|
|
312
|
+
if ((0, _util.isUndefined)(touch.height)) touch.height = touch.radiusY || 1;
|
|
313
|
+
if ((0, _util.isUndefined)(touch.tiltX)) touch.tiltX = 0;
|
|
314
|
+
if ((0, _util.isUndefined)(touch.tiltY)) touch.tiltY = 0;
|
|
315
|
+
if ((0, _util.isUndefined)(touch.pointerType)) touch.pointerType = 'touch'; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Touch/identifier
|
|
316
|
+
|
|
317
|
+
if ((0, _util.isUndefined)(touch.pointerId)) touch.pointerId = touch.identifier || 0;
|
|
318
|
+
if ((0, _util.isUndefined)(touch.pressure)) touch.pressure = touch.force || 0.5;
|
|
319
|
+
if ((0, _util.isUndefined)(touch.twist)) touch.twist = 0;
|
|
320
|
+
if ((0, _util.isUndefined)(touch.tangentialPressure)) touch.tangentialPressure = 0;
|
|
321
|
+
touch.isNormalized = true;
|
|
322
|
+
touch.type = event.type;
|
|
323
|
+
normalizedEvents.push(touch);
|
|
324
|
+
}
|
|
325
|
+
} else if (canvas.isMouseEvent(event)) {
|
|
326
|
+
var tempEvent = event;
|
|
327
|
+
if ((0, _util.isUndefined)(tempEvent.isPrimary)) tempEvent.isPrimary = true;
|
|
328
|
+
if ((0, _util.isUndefined)(tempEvent.width)) tempEvent.width = 1;
|
|
329
|
+
if ((0, _util.isUndefined)(tempEvent.height)) tempEvent.height = 1;
|
|
330
|
+
if ((0, _util.isUndefined)(tempEvent.tiltX)) tempEvent.tiltX = 0;
|
|
331
|
+
if ((0, _util.isUndefined)(tempEvent.tiltY)) tempEvent.tiltY = 0;
|
|
332
|
+
if ((0, _util.isUndefined)(tempEvent.pointerType)) tempEvent.pointerType = 'mouse';
|
|
333
|
+
if ((0, _util.isUndefined)(tempEvent.pointerId)) tempEvent.pointerId = _event.MOUSE_POINTER_ID;
|
|
334
|
+
if ((0, _util.isUndefined)(tempEvent.pressure)) tempEvent.pressure = 0.5;
|
|
335
|
+
if ((0, _util.isUndefined)(tempEvent.twist)) tempEvent.twist = 0;
|
|
336
|
+
if ((0, _util.isUndefined)(tempEvent.tangentialPressure)) tempEvent.tangentialPressure = 0;
|
|
337
|
+
tempEvent.isNormalized = true;
|
|
338
|
+
normalizedEvents.push(tempEvent);
|
|
339
|
+
} else {
|
|
340
|
+
normalizedEvents.push(event);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return normalizedEvents;
|
|
344
|
+
};
|
|
345
|
+
|
|
293
346
|
var EventPlugin_1;
|
|
294
347
|
EventPlugin.tag = 'EventPlugin';
|
|
295
348
|
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(_types.CanvasConfig), (0, _tslib.__metadata)("design:type", Object)], EventPlugin.prototype, "canvasConfig", void 0);
|
|
@@ -2,5 +2,6 @@ import type { RenderingService, RenderingPlugin } from '../services/RenderingSer
|
|
|
2
2
|
export declare class PrepareRendererPlugin implements RenderingPlugin {
|
|
3
3
|
static tag: string;
|
|
4
4
|
private renderingContext;
|
|
5
|
+
private styleValueRegistry;
|
|
5
6
|
apply(renderingService: RenderingService): void;
|
|
6
7
|
}
|
|
@@ -7,15 +7,11 @@ exports.PrepareRendererPlugin = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _tslib = require("tslib");
|
|
9
9
|
|
|
10
|
-
var _util = require("@antv/util");
|
|
11
|
-
|
|
12
10
|
var _manaSyringe = require("mana-syringe");
|
|
13
11
|
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
var _globalModule = require("../global-module");
|
|
12
|
+
var _css = require("../css");
|
|
17
13
|
|
|
18
|
-
var
|
|
14
|
+
var _dom = require("../dom");
|
|
19
15
|
|
|
20
16
|
var _services = require("../services");
|
|
21
17
|
|
|
@@ -29,8 +25,11 @@ function () {
|
|
|
29
25
|
PrepareRendererPlugin.prototype.apply = function (renderingService) {
|
|
30
26
|
var _this = this;
|
|
31
27
|
|
|
32
|
-
var handleAttributeChanged = function handleAttributeChanged() {
|
|
33
|
-
|
|
28
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
29
|
+
// this.renderingContext.renderReasons.add(RenderReason.DISPLAY_OBJECT_CHANGED);
|
|
30
|
+
var object = e.target;
|
|
31
|
+
object.renderable.dirty = true;
|
|
32
|
+
renderingService.dirtify();
|
|
34
33
|
};
|
|
35
34
|
|
|
36
35
|
var handleBoundsChanged = function handleBoundsChanged() {
|
|
@@ -38,19 +37,9 @@ function () {
|
|
|
38
37
|
};
|
|
39
38
|
|
|
40
39
|
var handleMounted = function handleMounted(e) {
|
|
41
|
-
var object = e.target; //
|
|
42
|
-
|
|
43
|
-
_globalModule.INHERIT_PROPERTIES.forEach(function (name) {
|
|
44
|
-
if (object.getAttribute(name) === 'inherit') {
|
|
45
|
-
var computedValue = (0, _propertyHandlers.computeInheritStyleProperty)(object, name);
|
|
40
|
+
var object = e.target; // recalc style values
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
var oldParsedValue = object.parsedStyle[name];
|
|
49
|
-
object.parsedStyle[name] = computedValue;
|
|
50
|
-
object.updateStyleProperty(name, oldParsedValue, computedValue);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
42
|
+
_this.styleValueRegistry.recalc(object);
|
|
54
43
|
|
|
55
44
|
(0, _services.dirtifyToRoot)(object);
|
|
56
45
|
renderingService.dirtify();
|
|
@@ -84,6 +73,7 @@ function () {
|
|
|
84
73
|
var PrepareRendererPlugin_1;
|
|
85
74
|
PrepareRendererPlugin.tag = 'PrepareRendererPlugin';
|
|
86
75
|
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(_services.RenderingContext), (0, _tslib.__metadata)("design:type", Object)], PrepareRendererPlugin.prototype, "renderingContext", void 0);
|
|
76
|
+
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(_css.StyleValueRegistry), (0, _tslib.__metadata)("design:type", _css.StyleValueRegistry)], PrepareRendererPlugin.prototype, "styleValueRegistry", void 0);
|
|
87
77
|
PrepareRendererPlugin = PrepareRendererPlugin_1 = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
|
|
88
78
|
contrib: _services.RenderingPluginContribution
|
|
89
79
|
})], PrepareRendererPlugin);
|
|
@@ -43,6 +43,7 @@ export declare class EventService extends EventEmitter {
|
|
|
43
43
|
propagate(e: FederatedEvent, type?: string): void;
|
|
44
44
|
propagationPath(target: IEventTarget): IEventTarget[];
|
|
45
45
|
hitTest(position: EventPosition): Promise<IEventTarget | null>;
|
|
46
|
+
private isNativeEventFromCanvas;
|
|
46
47
|
private createPointerEvent;
|
|
47
48
|
private createWheelEvent;
|
|
48
49
|
private trackingData;
|
|
@@ -7,6 +7,8 @@ exports.EventService = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _tslib = require("tslib");
|
|
9
9
|
|
|
10
|
+
var _glMatrix = require("gl-matrix");
|
|
11
|
+
|
|
10
12
|
var _manaSyringe = require("mana-syringe");
|
|
11
13
|
|
|
12
14
|
var _eventemitter = require("eventemitter3");
|
|
@@ -29,8 +31,6 @@ var _shapes = require("../shapes");
|
|
|
29
31
|
|
|
30
32
|
var _ContextService = require("./ContextService");
|
|
31
33
|
|
|
32
|
-
var _glMatrix = require("gl-matrix");
|
|
33
|
-
|
|
34
34
|
var PROPAGATION_LIMIT = 2048;
|
|
35
35
|
|
|
36
36
|
var EventService =
|
|
@@ -497,12 +497,6 @@ function (_super) {
|
|
|
497
497
|
}
|
|
498
498
|
|
|
499
499
|
EventService.prototype.init = function () {
|
|
500
|
-
// this.onPointerDown = this.onPointerDown.bind(this);
|
|
501
|
-
// this.onPointerMove = this.onPointerUp.bind(this);
|
|
502
|
-
// this.onPointerMove = this.onPointerMove.bind(this);
|
|
503
|
-
// this.onPointerUp = this.onPointerUp.bind(this);
|
|
504
|
-
// this.onPointerOut = this.onPointerOut.bind(this);
|
|
505
|
-
// this.onWheel = this.onWheel.bind(this);
|
|
506
500
|
this.rootTarget = this.renderingContext.root.parentNode; // document
|
|
507
501
|
|
|
508
502
|
this.addEventMapping('pointerdown', this.onPointerDown);
|
|
@@ -698,19 +692,25 @@ function (_super) {
|
|
|
698
692
|
});
|
|
699
693
|
};
|
|
700
694
|
|
|
695
|
+
EventService.prototype.isNativeEventFromCanvas = function (event) {
|
|
696
|
+
var $el = this.contextService.getDomElement();
|
|
697
|
+
return event.nativeEvent.composedPath().indexOf($el) > -1;
|
|
698
|
+
};
|
|
699
|
+
|
|
701
700
|
EventService.prototype.createPointerEvent = function (from, type, target) {
|
|
702
701
|
return (0, _tslib.__awaiter)(this, void 0, void 0, function () {
|
|
703
|
-
var event, _a, _b;
|
|
702
|
+
var event, isFromCanvas, _a, _b, _c;
|
|
704
703
|
|
|
705
|
-
return (0, _tslib.__generator)(this, function (
|
|
706
|
-
switch (
|
|
704
|
+
return (0, _tslib.__generator)(this, function (_d) {
|
|
705
|
+
switch (_d.label) {
|
|
707
706
|
case 0:
|
|
708
707
|
event = this.allocateEvent(_FederatedPointerEvent.FederatedPointerEvent);
|
|
709
708
|
this.copyPointerData(from, event);
|
|
710
709
|
this.copyMouseData(from, event);
|
|
711
710
|
this.copyData(from, event);
|
|
712
711
|
event.nativeEvent = from.nativeEvent;
|
|
713
|
-
|
|
712
|
+
isFromCanvas = this.isNativeEventFromCanvas(event);
|
|
713
|
+
event.originalEvent = from;
|
|
714
714
|
_a = event;
|
|
715
715
|
if (!(target !== null && target !== void 0)) return [3
|
|
716
716
|
/*break*/
|
|
@@ -718,9 +718,13 @@ function (_super) {
|
|
|
718
718
|
_b = target;
|
|
719
719
|
return [3
|
|
720
720
|
/*break*/
|
|
721
|
-
,
|
|
721
|
+
, 4];
|
|
722
722
|
|
|
723
723
|
case 1:
|
|
724
|
+
_c = isFromCanvas;
|
|
725
|
+
if (!_c) return [3
|
|
726
|
+
/*break*/
|
|
727
|
+
, 3];
|
|
724
728
|
return [4
|
|
725
729
|
/*yield*/
|
|
726
730
|
, this.hitTest({
|
|
@@ -733,10 +737,14 @@ function (_super) {
|
|
|
733
737
|
})];
|
|
734
738
|
|
|
735
739
|
case 2:
|
|
736
|
-
|
|
737
|
-
|
|
740
|
+
_c = _d.sent();
|
|
741
|
+
_d.label = 3;
|
|
738
742
|
|
|
739
743
|
case 3:
|
|
744
|
+
_b = _c;
|
|
745
|
+
_d.label = 4;
|
|
746
|
+
|
|
747
|
+
case 4:
|
|
740
748
|
_a.target = _b;
|
|
741
749
|
|
|
742
750
|
if (typeof type === 'string') {
|
|
@@ -753,18 +761,23 @@ function (_super) {
|
|
|
753
761
|
|
|
754
762
|
EventService.prototype.createWheelEvent = function (from) {
|
|
755
763
|
return (0, _tslib.__awaiter)(this, void 0, void 0, function () {
|
|
756
|
-
var event, _a;
|
|
764
|
+
var event, isFromCanvas, _a, _b;
|
|
757
765
|
|
|
758
|
-
return (0, _tslib.__generator)(this, function (
|
|
759
|
-
switch (
|
|
766
|
+
return (0, _tslib.__generator)(this, function (_c) {
|
|
767
|
+
switch (_c.label) {
|
|
760
768
|
case 0:
|
|
761
769
|
event = this.allocateEvent(_FederatedWheelEvent.FederatedWheelEvent);
|
|
762
770
|
this.copyWheelData(from, event);
|
|
763
771
|
this.copyMouseData(from, event);
|
|
764
772
|
this.copyData(from, event);
|
|
765
773
|
event.nativeEvent = from.nativeEvent;
|
|
766
|
-
event.
|
|
774
|
+
event.originalEvent = from;
|
|
775
|
+
isFromCanvas = this.isNativeEventFromCanvas(event);
|
|
767
776
|
_a = event;
|
|
777
|
+
_b = isFromCanvas;
|
|
778
|
+
if (!_b) return [3
|
|
779
|
+
/*break*/
|
|
780
|
+
, 2];
|
|
768
781
|
return [4
|
|
769
782
|
/*yield*/
|
|
770
783
|
, this.hitTest({
|
|
@@ -777,7 +790,11 @@ function (_super) {
|
|
|
777
790
|
})];
|
|
778
791
|
|
|
779
792
|
case 1:
|
|
780
|
-
|
|
793
|
+
_b = _c.sent();
|
|
794
|
+
_c.label = 2;
|
|
795
|
+
|
|
796
|
+
case 2:
|
|
797
|
+
_a.target = _b;
|
|
781
798
|
return [2
|
|
782
799
|
/*return*/
|
|
783
800
|
, event];
|
|
@@ -801,7 +818,7 @@ function (_super) {
|
|
|
801
818
|
EventService.prototype.clonePointerEvent = function (from, type) {
|
|
802
819
|
var event = this.allocateEvent(_FederatedPointerEvent.FederatedPointerEvent);
|
|
803
820
|
event.nativeEvent = from.nativeEvent;
|
|
804
|
-
event.
|
|
821
|
+
event.originalEvent = from.originalEvent;
|
|
805
822
|
this.copyPointerData(from, event);
|
|
806
823
|
this.copyMouseData(from, event);
|
|
807
824
|
this.copyData(from, event);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="offscreencanvas" />
|
|
2
|
+
/**
|
|
3
|
+
* used in following scenes:
|
|
4
|
+
* - g `ctx.measureText`
|
|
5
|
+
* - g-plugin-canvas-picker `ctx.isPointInPath`
|
|
6
|
+
* - g-plugin-webgl-renderer `ctx.createLinearGradient` and generate texture
|
|
7
|
+
*/
|
|
8
|
+
export declare class OffscreenCanvasCreator {
|
|
9
|
+
private canvas;
|
|
10
|
+
private context;
|
|
11
|
+
getOrCreateCanvas(offscreenCanvas: HTMLCanvasElement | OffscreenCanvas): HTMLCanvasElement | OffscreenCanvas;
|
|
12
|
+
getOrCreateContext(offscreenCanvas: HTMLCanvasElement | OffscreenCanvas): CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
13
|
+
}
|
|
@@ -9,29 +9,40 @@ var _tslib = require("tslib");
|
|
|
9
9
|
|
|
10
10
|
var _manaSyringe = require("mana-syringe");
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* used in following scenes:
|
|
14
|
+
* - g `ctx.measureText`
|
|
15
|
+
* - g-plugin-canvas-picker `ctx.isPointInPath`
|
|
16
|
+
* - g-plugin-webgl-renderer `ctx.createLinearGradient` and generate texture
|
|
17
|
+
*/
|
|
12
18
|
var OffscreenCanvasCreator =
|
|
13
19
|
/** @class */
|
|
14
20
|
function () {
|
|
15
21
|
function OffscreenCanvasCreator() {}
|
|
16
22
|
|
|
17
|
-
OffscreenCanvasCreator.prototype.getOrCreateCanvas = function () {
|
|
23
|
+
OffscreenCanvasCreator.prototype.getOrCreateCanvas = function (offscreenCanvas) {
|
|
18
24
|
if (this.canvas) {
|
|
19
25
|
return this.canvas;
|
|
20
|
-
}
|
|
26
|
+
} // user-defined offscreen canvas
|
|
27
|
+
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
this.canvas = new window.OffscreenCanvas(0, 0);
|
|
29
|
+
if (offscreenCanvas) {
|
|
30
|
+
this.canvas = offscreenCanvas;
|
|
26
31
|
this.context = this.canvas.getContext('2d');
|
|
32
|
+
} else {
|
|
33
|
+
try {
|
|
34
|
+
// OffscreenCanvas2D measureText can be up to 40% faster.
|
|
35
|
+
this.canvas = new window.OffscreenCanvas(0, 0);
|
|
36
|
+
this.context = this.canvas.getContext('2d');
|
|
27
37
|
|
|
28
|
-
|
|
38
|
+
if (!this.context || !this.context.measureText) {
|
|
39
|
+
this.canvas = document.createElement('canvas');
|
|
40
|
+
this.context = this.canvas.getContext('2d');
|
|
41
|
+
}
|
|
42
|
+
} catch (ex) {
|
|
29
43
|
this.canvas = document.createElement('canvas');
|
|
30
44
|
this.context = this.canvas.getContext('2d');
|
|
31
45
|
}
|
|
32
|
-
} catch (ex) {
|
|
33
|
-
this.canvas = document.createElement('canvas');
|
|
34
|
-
this.context = this.canvas.getContext('2d');
|
|
35
46
|
}
|
|
36
47
|
|
|
37
48
|
this.canvas.width = 10;
|
|
@@ -39,12 +50,12 @@ function () {
|
|
|
39
50
|
return this.canvas;
|
|
40
51
|
};
|
|
41
52
|
|
|
42
|
-
OffscreenCanvasCreator.prototype.getOrCreateContext = function () {
|
|
53
|
+
OffscreenCanvasCreator.prototype.getOrCreateContext = function (offscreenCanvas) {
|
|
43
54
|
if (this.context) {
|
|
44
55
|
return this.context;
|
|
45
56
|
}
|
|
46
57
|
|
|
47
|
-
this.getOrCreateCanvas();
|
|
58
|
+
this.getOrCreateCanvas(offscreenCanvas);
|
|
48
59
|
return this.context;
|
|
49
60
|
};
|
|
50
61
|
|
|
@@ -7,8 +7,15 @@ export interface RenderingPlugin {
|
|
|
7
7
|
}
|
|
8
8
|
export declare const RenderingPluginContribution: Syringe.DefinedToken;
|
|
9
9
|
export interface PickingResult {
|
|
10
|
+
/**
|
|
11
|
+
* position in canvas coordinate
|
|
12
|
+
*/
|
|
10
13
|
position: EventPosition;
|
|
11
|
-
picked: DisplayObject
|
|
14
|
+
picked: DisplayObject[];
|
|
15
|
+
/**
|
|
16
|
+
* only return the topmost object if there are multiple objects overlapped
|
|
17
|
+
*/
|
|
18
|
+
topmost?: boolean;
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
21
|
* Use frame renderer implemented by `g-canvas/svg/webgl`, in every frame we do followings:
|
|
@@ -23,22 +30,48 @@ export declare class RenderingService {
|
|
|
23
30
|
private renderingPluginProvider;
|
|
24
31
|
private renderingContext;
|
|
25
32
|
private sceneGraphService;
|
|
33
|
+
private styleValueRegistry;
|
|
26
34
|
private inited;
|
|
27
35
|
private stats;
|
|
28
36
|
private zIndexCounter;
|
|
29
37
|
hooks: {
|
|
38
|
+
/**
|
|
39
|
+
* called before any frame rendered
|
|
40
|
+
*/
|
|
30
41
|
init: AsyncParallelHook<[], import("tapable").UnsetAdditionalOptions>;
|
|
31
|
-
|
|
42
|
+
/**
|
|
43
|
+
* only dirty object which has sth changed will be rendered
|
|
44
|
+
*/
|
|
45
|
+
dirtycheck: SyncWaterfallHook<[DisplayObject<any, any>], import("tapable").UnsetAdditionalOptions>;
|
|
46
|
+
/**
|
|
47
|
+
* do culling
|
|
48
|
+
*/
|
|
49
|
+
cull: SyncWaterfallHook<[DisplayObject<any, any>], import("tapable").UnsetAdditionalOptions>;
|
|
32
50
|
/**
|
|
33
51
|
* called at beginning of each frame, won't get called if nothing to re-render
|
|
34
52
|
*/
|
|
35
53
|
beginFrame: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
|
|
54
|
+
/**
|
|
55
|
+
* called before every dirty object get rendered
|
|
56
|
+
*/
|
|
36
57
|
beforeRender: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
|
|
58
|
+
/**
|
|
59
|
+
* called when every dirty object rendering even it's culled
|
|
60
|
+
*/
|
|
37
61
|
render: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
|
|
62
|
+
/**
|
|
63
|
+
* called after every dirty object get rendered
|
|
64
|
+
*/
|
|
38
65
|
afterRender: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
|
|
39
66
|
endFrame: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
|
|
40
67
|
destroy: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
|
|
68
|
+
/**
|
|
69
|
+
* use async but faster method such as GPU-based picking in `g-plugin-webgl-renderer`
|
|
70
|
+
*/
|
|
41
71
|
pick: AsyncSeriesWaterfallHook<[PickingResult], PickingResult>;
|
|
72
|
+
/**
|
|
73
|
+
* used in event system
|
|
74
|
+
*/
|
|
42
75
|
pointerDown: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
43
76
|
pointerUp: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
44
77
|
pointerMove: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
@@ -11,6 +11,8 @@ var _manaSyringe = require("mana-syringe");
|
|
|
11
11
|
|
|
12
12
|
var _tapable = require("tapable");
|
|
13
13
|
|
|
14
|
+
var _css = require("../css");
|
|
15
|
+
|
|
14
16
|
var _dom = require("../dom");
|
|
15
17
|
|
|
16
18
|
var _RenderingContext = require("./RenderingContext");
|
|
@@ -54,19 +56,51 @@ function () {
|
|
|
54
56
|
};
|
|
55
57
|
this.zIndexCounter = 0;
|
|
56
58
|
this.hooks = {
|
|
59
|
+
/**
|
|
60
|
+
* called before any frame rendered
|
|
61
|
+
*/
|
|
57
62
|
init: new _tapable.AsyncParallelHook(),
|
|
58
|
-
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* only dirty object which has sth changed will be rendered
|
|
66
|
+
*/
|
|
67
|
+
dirtycheck: new _tapable.SyncWaterfallHook(['object']),
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* do culling
|
|
71
|
+
*/
|
|
72
|
+
cull: new _tapable.SyncWaterfallHook(['object']),
|
|
59
73
|
|
|
60
74
|
/**
|
|
61
75
|
* called at beginning of each frame, won't get called if nothing to re-render
|
|
62
76
|
*/
|
|
63
77
|
beginFrame: new _tapable.SyncHook([]),
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* called before every dirty object get rendered
|
|
81
|
+
*/
|
|
64
82
|
beforeRender: new _tapable.SyncHook(['objectToRender']),
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* called when every dirty object rendering even it's culled
|
|
86
|
+
*/
|
|
65
87
|
render: new _tapable.SyncHook(['objectToRender']),
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* called after every dirty object get rendered
|
|
91
|
+
*/
|
|
66
92
|
afterRender: new _tapable.SyncHook(['objectToRender']),
|
|
67
93
|
endFrame: new _tapable.SyncHook([]),
|
|
68
94
|
destroy: new _tapable.SyncHook([]),
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* use async but faster method such as GPU-based picking in `g-plugin-webgl-renderer`
|
|
98
|
+
*/
|
|
69
99
|
pick: new _tapable.AsyncSeriesWaterfallHook(['result']),
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* used in event system
|
|
103
|
+
*/
|
|
70
104
|
pointerDown: new _tapable.SyncHook(['event']),
|
|
71
105
|
pointerUp: new _tapable.SyncHook(['event']),
|
|
72
106
|
pointerMove: new _tapable.SyncHook(['event']),
|
|
@@ -134,14 +168,18 @@ function () {
|
|
|
134
168
|
};
|
|
135
169
|
|
|
136
170
|
RenderingService.prototype.renderDisplayObject = function (displayObject) {
|
|
137
|
-
var _this = this; //
|
|
171
|
+
var _this = this; // recalc style values
|
|
138
172
|
|
|
139
173
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
174
|
+
this.styleValueRegistry.recalc(displayObject); // TODO: relayout
|
|
175
|
+
// dirtycheck first
|
|
176
|
+
|
|
177
|
+
var objectChanged = this.hooks.dirtycheck.call(displayObject);
|
|
178
|
+
|
|
179
|
+
if (objectChanged) {
|
|
180
|
+
// const objectToRender = this.hooks.cull.call(objectChanged);
|
|
181
|
+
this.hooks.cull.call(objectChanged); // if (objectToRender) {
|
|
143
182
|
|
|
144
|
-
if (objectToRender) {
|
|
145
183
|
this.stats.rendered++;
|
|
146
184
|
|
|
147
185
|
if (!this.renderingContext.dirty) {
|
|
@@ -149,12 +187,14 @@ function () {
|
|
|
149
187
|
this.hooks.beginFrame.call();
|
|
150
188
|
}
|
|
151
189
|
|
|
152
|
-
this.hooks.beforeRender.call(
|
|
153
|
-
this.hooks.render.call(
|
|
154
|
-
this.hooks.afterRender.call(
|
|
155
|
-
displayObject.renderable.dirty = false;
|
|
156
|
-
}
|
|
190
|
+
this.hooks.beforeRender.call(objectChanged);
|
|
191
|
+
this.hooks.render.call(objectChanged);
|
|
192
|
+
this.hooks.afterRender.call(objectChanged);
|
|
193
|
+
displayObject.renderable.dirty = false; // }
|
|
194
|
+
}
|
|
157
195
|
|
|
196
|
+
displayObject.sortable.renderOrder = this.zIndexCounter++;
|
|
197
|
+
this.stats.total++; // sort is very expensive, use cached result if posible
|
|
158
198
|
|
|
159
199
|
var sortable = displayObject.sortable;
|
|
160
200
|
var renderOrderChanged = false;
|
|
@@ -192,6 +232,7 @@ function () {
|
|
|
192
232
|
(0, _tslib.__decorate)([(0, _manaSyringe.contrib)(RenderingPluginContribution), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "renderingPluginProvider", void 0);
|
|
193
233
|
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(_RenderingContext.RenderingContext), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "renderingContext", void 0);
|
|
194
234
|
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(_SceneGraphService.SceneGraphService), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "sceneGraphService", void 0);
|
|
235
|
+
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(_css.StyleValueRegistry), (0, _tslib.__metadata)("design:type", _css.StyleValueRegistry)], RenderingService.prototype, "styleValueRegistry", void 0);
|
|
195
236
|
RenderingService = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], RenderingService);
|
|
196
237
|
return RenderingService;
|
|
197
238
|
}();
|
|
@@ -8,11 +8,13 @@ export interface SceneGraphSelector {
|
|
|
8
8
|
is: <T extends IElement>(query: string, element: T) => boolean;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* support following DOM API
|
|
11
|
+
* support the following DOM API:
|
|
12
12
|
* * getElementById
|
|
13
13
|
* * getElementsByClassName
|
|
14
14
|
* * getElementsByName
|
|
15
15
|
* * getElementsByTag
|
|
16
|
+
* * querySelector
|
|
17
|
+
* * querySelectorAll
|
|
16
18
|
*/
|
|
17
19
|
export declare class DefaultSceneGraphSelector implements SceneGraphSelector {
|
|
18
20
|
selectOne<R extends IElement, T extends IElement>(query: string, root: R): T | null;
|