@antv/g 5.0.15 → 5.0.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/dist/index.umd.min.js +18 -2
- package/es/Canvas.d.ts +3 -0
- package/es/Canvas.js +8 -9
- package/es/camera/Camera.d.ts +3 -2
- package/es/camera/Camera.js +16 -8
- package/es/canvas-module.js +4 -2
- package/es/components/Transform.d.ts +0 -1
- package/es/components/Transform.js +0 -1
- package/es/display-objects/Circle.d.ts +1 -1
- package/es/display-objects/Circle.js +8 -3
- package/es/display-objects/CustomElement.d.ts +3 -2
- package/es/display-objects/CustomElement.js +9 -6
- package/es/display-objects/DisplayObject.d.ts +4 -3
- package/es/display-objects/DisplayObject.js +77 -50
- package/es/display-objects/Ellipse.d.ts +1 -1
- package/es/display-objects/Ellipse.js +8 -3
- package/es/display-objects/Group.d.ts +18 -2
- package/es/display-objects/Group.js +11 -9
- package/es/display-objects/HTML.d.ts +1 -1
- package/es/display-objects/HTML.js +9 -4
- package/es/display-objects/Image.d.ts +5 -3
- package/es/display-objects/Image.js +8 -3
- package/es/display-objects/Line.d.ts +1 -1
- package/es/display-objects/Line.js +12 -4
- package/es/display-objects/Path.d.ts +3 -2
- package/es/display-objects/Path.js +10 -5
- package/es/display-objects/Polygon.d.ts +1 -1
- package/es/display-objects/Polygon.js +9 -3
- package/es/display-objects/Polyline.d.ts +1 -1
- package/es/display-objects/Polyline.js +10 -5
- package/es/display-objects/Rect.d.ts +1 -1
- package/es/display-objects/Rect.js +8 -3
- package/es/display-objects/Text.d.ts +9 -4
- package/es/display-objects/Text.js +14 -9
- package/es/dom/Animation.js +1 -1
- package/es/dom/AnimationTimeline.js +1 -2
- package/es/dom/CustomElementRegistry.js +12 -12
- package/es/dom/Document.d.ts +1 -0
- package/es/dom/Document.js +21 -1
- package/es/dom/Element.d.ts +10 -5
- package/es/dom/Element.js +41 -15
- package/es/dom/EventTarget.d.ts +2 -2
- package/es/dom/EventTarget.js +4 -3
- package/es/dom/KeyframeList.js +1 -1
- package/es/dom/MutationEvent.d.ts +15 -0
- package/es/dom/MutationEvent.js +29 -0
- package/es/dom/MutationObserver.d.ts +36 -0
- package/es/dom/MutationObserver.js +413 -0
- package/es/dom/MutationRecord.d.ts +14 -0
- package/es/dom/MutationRecord.js +31 -0
- package/es/dom/Node.d.ts +35 -3
- package/es/dom/Node.js +184 -17
- package/es/dom/index.d.ts +3 -0
- package/es/dom/index.js +3 -0
- package/es/dom/interfaces.d.ts +36 -8
- package/es/dom/interfaces.js +23 -5
- package/es/global-module.d.ts +1 -0
- package/es/global-module.js +11 -13
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/plugins/CullingPlugin.d.ts +0 -2
- package/es/plugins/CullingPlugin.js +3 -24
- package/es/plugins/DirtyCheckPlugin.js +2 -2
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/es/plugins/FrustumCullingStrategy.js +40 -33
- package/es/plugins/PrepareRendererPlugin.js +21 -5
- package/es/property-handlers/aabb.js +19 -20
- package/es/property-handlers/color.js +5 -2
- package/es/property-handlers/dimension.d.ts +15 -3
- package/es/property-handlers/dimension.js +50 -9
- package/es/property-handlers/index.d.ts +3 -0
- package/es/property-handlers/index.js +4 -1
- package/es/property-handlers/inherit.d.ts +6 -0
- package/es/property-handlers/inherit.js +25 -0
- package/es/property-handlers/interfaces.d.ts +2 -2
- package/es/property-handlers/lineDash.d.ts +6 -1
- package/es/property-handlers/lineDash.js +23 -4
- package/es/property-handlers/offsetDistance.js +2 -2
- package/es/property-handlers/text.d.ts +2 -0
- package/es/property-handlers/text.js +3 -0
- package/es/property-handlers/textTransform.d.ts +6 -0
- package/es/property-handlers/textTransform.js +19 -0
- package/es/services/EventService.js +3 -5
- package/es/services/RenderingContext.d.ts +5 -8
- package/es/services/RenderingContext.js +6 -7
- package/es/services/RenderingService.js +2 -8
- package/es/services/SceneGraphSelector.d.ts +3 -2
- package/es/services/SceneGraphSelector.js +8 -4
- package/es/services/SceneGraphService.d.ts +0 -7
- package/es/services/SceneGraphService.js +9 -77
- package/es/services/aabb/CircleUpdater.js +3 -3
- package/es/services/aabb/EllipseUpdater.js +2 -2
- package/es/services/aabb/LineUpdater.js +2 -2
- package/es/services/aabb/PathUpdater.js +2 -2
- package/es/services/aabb/PolylineUpdater.js +3 -3
- package/es/services/aabb/RectUpdater.js +4 -4
- package/es/services/aabb/TextUpdater.js +19 -10
- package/es/services/text/index.js +19 -21
- package/es/types.d.ts +48 -24
- package/es/types.js +50 -31
- package/es/utils/custom-easing.js +1 -1
- package/es/utils/event.js +5 -3
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/interpolation.d.ts +1 -0
- package/es/utils/interpolation.js +41 -8
- package/es/utils/path.js +11 -11
- package/es/utils/raf.d.ts +1 -1
- package/es/utils/raf.js +0 -2
- package/es/utils/string.d.ts +1 -0
- package/es/utils/string.js +9 -0
- package/es/utils/text.js +3 -3
- package/lib/Canvas.d.ts +3 -0
- package/lib/Canvas.js +6 -7
- package/lib/camera/Camera.d.ts +3 -2
- package/lib/camera/Camera.js +20 -10
- package/lib/canvas-module.js +3 -1
- package/lib/components/Transform.d.ts +0 -1
- package/lib/components/Transform.js +0 -1
- package/lib/display-objects/Circle.d.ts +1 -1
- package/lib/display-objects/Circle.js +7 -2
- package/lib/display-objects/CustomElement.d.ts +3 -2
- package/lib/display-objects/CustomElement.js +9 -6
- package/lib/display-objects/DisplayObject.d.ts +4 -3
- package/lib/display-objects/DisplayObject.js +76 -47
- package/lib/display-objects/Ellipse.d.ts +1 -1
- package/lib/display-objects/Ellipse.js +7 -2
- package/lib/display-objects/Group.d.ts +18 -2
- package/lib/display-objects/Group.js +10 -9
- package/lib/display-objects/HTML.d.ts +1 -1
- package/lib/display-objects/HTML.js +8 -4
- package/lib/display-objects/Image.d.ts +5 -3
- package/lib/display-objects/Image.js +7 -2
- package/lib/display-objects/Line.d.ts +1 -1
- package/lib/display-objects/Line.js +11 -3
- package/lib/display-objects/Path.d.ts +3 -2
- package/lib/display-objects/Path.js +9 -4
- package/lib/display-objects/Polygon.d.ts +1 -1
- package/lib/display-objects/Polygon.js +8 -2
- package/lib/display-objects/Polyline.d.ts +1 -1
- package/lib/display-objects/Polyline.js +9 -4
- package/lib/display-objects/Rect.d.ts +1 -1
- package/lib/display-objects/Rect.js +7 -2
- package/lib/display-objects/Text.d.ts +9 -4
- package/lib/display-objects/Text.js +13 -8
- package/lib/dom/Animation.js +1 -1
- package/lib/dom/AnimationTimeline.js +1 -2
- package/lib/dom/CustomElementRegistry.js +11 -11
- package/lib/dom/Document.d.ts +1 -0
- package/lib/dom/Document.js +22 -1
- package/lib/dom/Element.d.ts +10 -5
- package/lib/dom/Element.js +43 -15
- package/lib/dom/EventTarget.d.ts +2 -2
- package/lib/dom/EventTarget.js +4 -3
- package/lib/dom/KeyframeList.js +1 -1
- package/lib/dom/MutationEvent.d.ts +15 -0
- package/lib/dom/MutationEvent.js +37 -0
- package/lib/dom/MutationObserver.d.ts +36 -0
- package/lib/dom/MutationObserver.js +424 -0
- package/lib/dom/MutationRecord.d.ts +14 -0
- package/lib/dom/MutationRecord.js +38 -0
- package/lib/dom/Node.d.ts +35 -3
- package/lib/dom/Node.js +185 -16
- package/lib/dom/index.d.ts +3 -0
- package/lib/dom/index.js +39 -0
- package/lib/dom/interfaces.d.ts +36 -8
- package/lib/dom/interfaces.js +23 -5
- package/lib/global-module.d.ts +1 -0
- package/lib/global-module.js +12 -8
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/plugins/CullingPlugin.d.ts +0 -2
- package/lib/plugins/CullingPlugin.js +2 -23
- package/lib/plugins/DirtyCheckPlugin.js +1 -1
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/lib/plugins/FrustumCullingStrategy.js +41 -33
- package/lib/plugins/PrepareRendererPlugin.js +24 -4
- package/lib/property-handlers/aabb.js +18 -19
- package/lib/property-handlers/color.js +6 -3
- package/lib/property-handlers/dimension.d.ts +15 -3
- package/lib/property-handlers/dimension.js +50 -8
- package/lib/property-handlers/index.d.ts +3 -0
- package/lib/property-handlers/index.js +39 -0
- package/lib/property-handlers/inherit.d.ts +6 -0
- package/lib/property-handlers/inherit.js +34 -0
- package/lib/property-handlers/interfaces.d.ts +2 -2
- package/lib/property-handlers/lineDash.d.ts +6 -1
- package/lib/property-handlers/lineDash.js +25 -4
- package/lib/property-handlers/offsetDistance.js +1 -1
- package/lib/property-handlers/text.d.ts +2 -0
- package/lib/property-handlers/text.js +10 -0
- package/lib/property-handlers/textTransform.d.ts +6 -0
- package/lib/property-handlers/textTransform.js +27 -0
- package/lib/services/EventService.js +3 -5
- package/lib/services/RenderingContext.d.ts +5 -8
- package/lib/services/RenderingContext.js +8 -9
- package/lib/services/RenderingService.js +1 -7
- package/lib/services/SceneGraphSelector.d.ts +3 -2
- package/lib/services/SceneGraphSelector.js +10 -3
- package/lib/services/SceneGraphService.d.ts +0 -7
- package/lib/services/SceneGraphService.js +10 -77
- package/lib/services/aabb/CircleUpdater.js +2 -2
- package/lib/services/aabb/EllipseUpdater.js +1 -1
- package/lib/services/aabb/LineUpdater.js +1 -1
- package/lib/services/aabb/PathUpdater.js +1 -1
- package/lib/services/aabb/PolylineUpdater.js +2 -2
- package/lib/services/aabb/RectUpdater.js +3 -3
- package/lib/services/aabb/TextUpdater.js +18 -9
- package/lib/services/text/index.js +19 -21
- package/lib/types.d.ts +48 -24
- package/lib/types.js +56 -35
- package/lib/utils/custom-easing.js +1 -1
- package/lib/utils/event.js +5 -3
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/interpolation.d.ts +1 -0
- package/lib/utils/interpolation.js +43 -7
- package/lib/utils/path.js +10 -10
- package/lib/utils/raf.d.ts +1 -1
- package/lib/utils/raf.js +0 -2
- package/lib/utils/string.d.ts +1 -0
- package/lib/utils/string.js +16 -0
- package/lib/utils/text.js +3 -3
- package/package.json +5 -3
package/es/types.js
CHANGED
|
@@ -1,33 +1,52 @@
|
|
|
1
|
-
export var
|
|
2
|
-
|
|
3
|
-
(function (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})(
|
|
16
|
-
|
|
17
|
-
export var
|
|
18
|
-
|
|
19
|
-
(function (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})(
|
|
24
|
-
|
|
25
|
-
export var
|
|
26
|
-
|
|
27
|
-
(function (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})(
|
|
1
|
+
export var Shape;
|
|
2
|
+
|
|
3
|
+
(function (Shape) {
|
|
4
|
+
Shape["GROUP"] = "g";
|
|
5
|
+
Shape["CIRCLE"] = "circle";
|
|
6
|
+
Shape["ELLIPSE"] = "ellipse";
|
|
7
|
+
Shape["IMAGE"] = "image";
|
|
8
|
+
Shape["RECT"] = "rect";
|
|
9
|
+
Shape["LINE"] = "line";
|
|
10
|
+
Shape["POLYLINE"] = "polyline";
|
|
11
|
+
Shape["POLYGON"] = "polygon";
|
|
12
|
+
Shape["TEXT"] = "text";
|
|
13
|
+
Shape["PATH"] = "path";
|
|
14
|
+
Shape["HTML"] = "html";
|
|
15
|
+
})(Shape || (Shape = {}));
|
|
16
|
+
|
|
17
|
+
export var LineCap;
|
|
18
|
+
|
|
19
|
+
(function (LineCap) {
|
|
20
|
+
LineCap["BUTT"] = "butt";
|
|
21
|
+
LineCap["ROUND"] = "round";
|
|
22
|
+
LineCap["SQUARE"] = "square";
|
|
23
|
+
})(LineCap || (LineCap = {}));
|
|
24
|
+
|
|
25
|
+
export var LineJoin;
|
|
26
|
+
|
|
27
|
+
(function (LineJoin) {
|
|
28
|
+
LineJoin["BEVEL"] = "bevel";
|
|
29
|
+
LineJoin["ROUND"] = "round";
|
|
30
|
+
LineJoin["MITER"] = "miter";
|
|
31
|
+
})(LineJoin || (LineJoin = {}));
|
|
32
|
+
|
|
33
|
+
export var TextTransform;
|
|
34
|
+
|
|
35
|
+
(function (TextTransform) {
|
|
36
|
+
TextTransform["CAPITALIZE"] = "capitalize";
|
|
37
|
+
TextTransform["UPPERCASE"] = "uppercase";
|
|
38
|
+
TextTransform["LOWERCASE"] = "lowercase";
|
|
39
|
+
TextTransform["NONE"] = "none";
|
|
40
|
+
})(TextTransform || (TextTransform = {}));
|
|
41
|
+
|
|
42
|
+
export var TextAlign;
|
|
43
|
+
|
|
44
|
+
(function (TextAlign) {
|
|
45
|
+
TextAlign["START"] = "start";
|
|
46
|
+
TextAlign["CENTER"] = "center";
|
|
47
|
+
TextAlign["END"] = "end";
|
|
48
|
+
TextAlign["LEFT"] = "left";
|
|
49
|
+
TextAlign["RIGHT"] = "right";
|
|
50
|
+
})(TextAlign || (TextAlign = {}));
|
|
32
51
|
|
|
33
52
|
export var CanvasConfig = 'CanvasConfig';
|
|
@@ -6,7 +6,7 @@ import { __read, __spreadArray } from "tslib";
|
|
|
6
6
|
import { bezier } from './bezier-easing';
|
|
7
7
|
export var convertToDash = function convertToDash(str) {
|
|
8
8
|
str = str.replace(/([A-Z])/g, function (letter) {
|
|
9
|
-
return "-"
|
|
9
|
+
return "-".concat(letter.toLowerCase());
|
|
10
10
|
}); // Remove first dash
|
|
11
11
|
|
|
12
12
|
return str.charAt(0) === '-' ? str.substr(1) : str;
|
package/es/utils/event.js
CHANGED
|
@@ -26,9 +26,11 @@ export function normalizeToPointerEvent(event) {
|
|
|
26
26
|
|
|
27
27
|
if (isTouchEvent(event)) {
|
|
28
28
|
for (var i = 0; i < event.changedTouches.length; i++) {
|
|
29
|
-
var touch = event.changedTouches[i];
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
var touch = event.changedTouches[i]; // use changedTouches instead of touches since touchend has no touches
|
|
30
|
+
// @see https://stackoverflow.com/a/10079076
|
|
31
|
+
|
|
32
|
+
if (isUndefined(touch.button)) touch.button = event.changedTouches.length ? 1 : 0;
|
|
33
|
+
if (isUndefined(touch.buttons)) touch.buttons = event.changedTouches.length ? 1 : 0;
|
|
32
34
|
|
|
33
35
|
if (isUndefined(touch.isPrimary)) {
|
|
34
36
|
touch.isPrimary = event.touches.length === 1 && event.type === 'touchstart';
|
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { AnimationEffectTiming } from '../dom';
|
|
2
2
|
import type { IElement } from '../dom/interfaces';
|
|
3
3
|
export declare function convertEffectInput(keyframes: ComputedKeyframe[], timing: AnimationEffectTiming, target: IElement | null): (target: IElement, fraction: number) => void;
|
|
4
|
+
export declare function formatAttribute(name: string, value: any): [string, any];
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
|
-
import { stylePropertyMergerFactory, stylePropertyParserFactory } from '../global-module';
|
|
3
|
-
// StylePropertyMergerFactory,
|
|
4
|
-
// StylePropertyParserFactory,
|
|
5
|
-
// } from '../property-handlers/interfaces';
|
|
6
|
-
|
|
2
|
+
import { stylePropertyMergerFactory, stylePropertyParserFactory } from '../global-module';
|
|
7
3
|
import { parseEasingFunction } from './animation';
|
|
4
|
+
import { camelCase } from './string';
|
|
8
5
|
export function convertEffectInput(keyframes, timing, target) {
|
|
9
6
|
var propertySpecificKeyframeGroups = makePropertySpecificKeyframeGroups(keyframes, timing);
|
|
10
7
|
var interpolations = makeInterpolations(propertySpecificKeyframeGroups, target);
|
|
@@ -120,9 +117,9 @@ function propertyInterpolation(property, left, right, target) {
|
|
|
120
117
|
|
|
121
118
|
if (parser) {
|
|
122
119
|
// @ts-ignore
|
|
123
|
-
parsedLeft = parser(left, target); // @ts-ignore
|
|
120
|
+
parsedLeft = parser(left, target, property); // @ts-ignore
|
|
124
121
|
|
|
125
|
-
parsedRight = parser(right, target);
|
|
122
|
+
parsedRight = parser(right, target, property);
|
|
126
123
|
} // merger [left, right, n2string()]
|
|
127
124
|
|
|
128
125
|
|
|
@@ -179,4 +176,40 @@ convertToString) {
|
|
|
179
176
|
return function (f) {
|
|
180
177
|
return convertToString(interpolate(from, to, f));
|
|
181
178
|
};
|
|
182
|
-
};
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
var FORMAT_ATTR_MAP = {
|
|
182
|
+
d: {
|
|
183
|
+
alias: 'path'
|
|
184
|
+
},
|
|
185
|
+
cx: {
|
|
186
|
+
alias: 'x'
|
|
187
|
+
},
|
|
188
|
+
cy: {
|
|
189
|
+
alias: 'y'
|
|
190
|
+
},
|
|
191
|
+
strokeDasharray: {
|
|
192
|
+
alias: 'lineDash'
|
|
193
|
+
},
|
|
194
|
+
strokeWidth: {
|
|
195
|
+
alias: 'lineWidth'
|
|
196
|
+
},
|
|
197
|
+
textAnchor: {
|
|
198
|
+
alias: 'textAlign',
|
|
199
|
+
values: {
|
|
200
|
+
middle: 'center'
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
src: {
|
|
204
|
+
alias: 'img'
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
export function formatAttribute(name, value) {
|
|
208
|
+
var _a;
|
|
209
|
+
|
|
210
|
+
var attributeName = camelCase(name);
|
|
211
|
+
var map = FORMAT_ATTR_MAP[attributeName];
|
|
212
|
+
attributeName = (map === null || map === void 0 ? void 0 : map.alias) || attributeName;
|
|
213
|
+
var attributeValue = ((_a = map === null || map === void 0 ? void 0 : map.values) === null || _a === void 0 ? void 0 : _a[value]) || value;
|
|
214
|
+
return [attributeName, attributeValue];
|
|
215
|
+
}
|
package/es/utils/path.js
CHANGED
|
@@ -6,7 +6,7 @@ import { __read, __spreadArray } from "tslib";
|
|
|
6
6
|
|
|
7
7
|
import { Cubic as CubicUtil } from '@antv/g-math';
|
|
8
8
|
import { vec3 } from 'gl-matrix';
|
|
9
|
-
import {
|
|
9
|
+
import { Shape } from '../types';
|
|
10
10
|
|
|
11
11
|
function midPoint(a, b, t) {
|
|
12
12
|
var ax = a[0];
|
|
@@ -214,7 +214,7 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
|
|
|
214
214
|
if (cur[0] === 'M' || cur[0] === 'L') {
|
|
215
215
|
var p = vec3.fromValues(cur[1] - x, cur[2] - y, 0);
|
|
216
216
|
vec3.transformMat4(p, p, localTransform);
|
|
217
|
-
path = ""
|
|
217
|
+
path = "".concat(cur[0]).concat(p[0], ",").concat(p[1]);
|
|
218
218
|
} else if (cur[0] === 'Z') {
|
|
219
219
|
path = cur[0];
|
|
220
220
|
} else if (cur[0] === 'C') {
|
|
@@ -224,11 +224,11 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
|
|
|
224
224
|
vec3.transformMat4(p1, p1, localTransform);
|
|
225
225
|
vec3.transformMat4(p2, p2, localTransform);
|
|
226
226
|
vec3.transformMat4(p3, p3, localTransform);
|
|
227
|
-
path = ""
|
|
227
|
+
path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
|
|
228
228
|
} else if (cur[0] === 'A') {
|
|
229
229
|
var c = vec3.fromValues(cur[6] - x, cur[7] - y, 0);
|
|
230
230
|
vec3.transformMat4(c, c, localTransform);
|
|
231
|
-
path = ""
|
|
231
|
+
path = "".concat(cur[0]).concat(cur[1], ",").concat(cur[2], ",").concat(cur[3], ",").concat(cur[4], ",").concat(cur[5], ",").concat(c[0], ",").concat(c[1]);
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
return prev += path;
|
|
@@ -278,7 +278,7 @@ export function convertToPath(object) {
|
|
|
278
278
|
var commands = [];
|
|
279
279
|
|
|
280
280
|
switch (object.nodeName) {
|
|
281
|
-
case
|
|
281
|
+
case Shape.LINE:
|
|
282
282
|
var _a = object.parsedStyle,
|
|
283
283
|
x1 = _a.x1,
|
|
284
284
|
y1 = _a.y1,
|
|
@@ -287,7 +287,7 @@ export function convertToPath(object) {
|
|
|
287
287
|
commands = lineToCommands(x1, y1, x2, y2);
|
|
288
288
|
break;
|
|
289
289
|
|
|
290
|
-
case
|
|
290
|
+
case Shape.CIRCLE:
|
|
291
291
|
{
|
|
292
292
|
var _b = object.parsedStyle,
|
|
293
293
|
r = _b.rInPixels,
|
|
@@ -299,7 +299,7 @@ export function convertToPath(object) {
|
|
|
299
299
|
break;
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
case
|
|
302
|
+
case Shape.ELLIPSE:
|
|
303
303
|
{
|
|
304
304
|
var _e = object.parsedStyle,
|
|
305
305
|
rx = _e.rxInPixels,
|
|
@@ -312,13 +312,13 @@ export function convertToPath(object) {
|
|
|
312
312
|
break;
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
case
|
|
316
|
-
case
|
|
315
|
+
case Shape.POLYLINE:
|
|
316
|
+
case Shape.POLYGON:
|
|
317
317
|
var points = object.parsedStyle.points;
|
|
318
318
|
commands = polygonToCommands(points.points);
|
|
319
319
|
break;
|
|
320
320
|
|
|
321
|
-
case
|
|
321
|
+
case Shape.RECT:
|
|
322
322
|
var _h = object.parsedStyle,
|
|
323
323
|
width = _h.widthInPixels,
|
|
324
324
|
height = _h.heightInPixels,
|
|
@@ -328,7 +328,7 @@ export function convertToPath(object) {
|
|
|
328
328
|
commands = rectToCommands(width, height, x, y, radius);
|
|
329
329
|
break;
|
|
330
330
|
|
|
331
|
-
case
|
|
331
|
+
case Shape.PATH:
|
|
332
332
|
commands = object.parsedStyle.path.curve;
|
|
333
333
|
break;
|
|
334
334
|
}
|
package/es/utils/raf.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* use user-defined raf instead of requestAnimationFrame
|
|
3
3
|
*/
|
|
4
|
-
export declare function patch(requestAFPatch: (callback:
|
|
4
|
+
export declare function patch(requestAFPatch: (callback: (timestamp: number) => void) => number, cancelAFPatch: (id: number) => void): void;
|
|
5
5
|
export declare const requestAnimationFrame: (callback: Function) => number;
|
|
6
6
|
export declare const cancelAnimationFrame: (id: number) => void;
|
package/es/utils/raf.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// import { requestAnimationFrame, cancelAnimationFrame } from 'request-animation-frame-polyfill';
|
|
2
|
-
// export { requestAnimationFrame, cancelAnimationFrame };
|
|
3
1
|
import { requestAnimationFrame as rAF, cancelAnimationFrame as cancelRAF } from 'request-animation-frame-polyfill';
|
|
4
2
|
var requestAF = rAF;
|
|
5
3
|
var cancelAF = cancelRAF;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function camelCase(str?: string): string;
|
package/es/utils/text.js
CHANGED
|
@@ -7,7 +7,7 @@ export function toFontString(attributes) {
|
|
|
7
7
|
fontVariant = attributes.fontVariant,
|
|
8
8
|
fontWeight = attributes.fontWeight; // build canvas api font setting from individual components. Convert a numeric this.fontSize to px
|
|
9
9
|
|
|
10
|
-
var fontSizeString = isNumber(fontSize) ? fontSize
|
|
10
|
+
var fontSizeString = isNumber(fontSize) ? "".concat(fontSize, "px") : "".concat(fontSize.value).concat(fontSize.unit || 'px'); // Clean-up fontFamily property by quoting each font name
|
|
11
11
|
// this will support font names with spaces
|
|
12
12
|
// @ts-ignore
|
|
13
13
|
|
|
@@ -22,11 +22,11 @@ export function toFontString(attributes) {
|
|
|
22
22
|
var fontFamily_1 = fontFamilies[i].trim(); // Check if font already contains strings
|
|
23
23
|
|
|
24
24
|
if (!/([\"\'])[^\'\"]+\1/.test(fontFamily_1) && genericFontFamilies.indexOf(fontFamily_1) < 0) {
|
|
25
|
-
fontFamily_1 = "\""
|
|
25
|
+
fontFamily_1 = "\"".concat(fontFamily_1, "\"");
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
fontFamilies[i] = fontFamily_1;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
return fontStyle
|
|
31
|
+
return "".concat(fontStyle, " ").concat(fontVariant, " ").concat(fontWeight, " ").concat(fontSizeString, " ").concat(fontFamilies.join(','));
|
|
32
32
|
}
|
package/lib/Canvas.d.ts
CHANGED
|
@@ -73,6 +73,9 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
73
73
|
total: number;
|
|
74
74
|
rendered: number;
|
|
75
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Window/getComputedStyle
|
|
78
|
+
*/
|
|
76
79
|
getComputedStyle(node: DisplayObject): any;
|
|
77
80
|
get ready(): Promise<any>;
|
|
78
81
|
destroy(destroyScenegraph?: boolean): void;
|
package/lib/Canvas.js
CHANGED
|
@@ -131,11 +131,6 @@ function (_super) {
|
|
|
131
131
|
* the root node in scene graph
|
|
132
132
|
*/
|
|
133
133
|
root: this.document.documentElement,
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* removed render bounds
|
|
137
|
-
*/
|
|
138
|
-
removedRenderBoundsList: [],
|
|
139
134
|
renderReasons: new Set(),
|
|
140
135
|
force: false,
|
|
141
136
|
dirty: false
|
|
@@ -154,8 +149,8 @@ function (_super) {
|
|
|
154
149
|
var camera = new _camera.Camera().setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0).setOrthographic(width / -2, width / 2, height / 2, height / -2, 0.1, 1000); // redraw when camera changed
|
|
155
150
|
|
|
156
151
|
var context = this.container.get(_RenderingContext.RenderingContext);
|
|
157
|
-
camera.on(_camera.
|
|
158
|
-
context.renderReasons.add(_RenderingContext.
|
|
152
|
+
camera.on(_camera.CameraEvent.UPDATED, function () {
|
|
153
|
+
context.renderReasons.add(_RenderingContext.RenderReason.CAMERA_CHANGED);
|
|
159
154
|
}); // bind camera
|
|
160
155
|
|
|
161
156
|
this.container.register({
|
|
@@ -208,6 +203,10 @@ function (_super) {
|
|
|
208
203
|
Canvas.prototype.getStats = function () {
|
|
209
204
|
return this.getRenderingService().getStats();
|
|
210
205
|
};
|
|
206
|
+
/**
|
|
207
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Window/getComputedStyle
|
|
208
|
+
*/
|
|
209
|
+
|
|
211
210
|
|
|
212
211
|
Canvas.prototype.getComputedStyle = function (node) {
|
|
213
212
|
return node.parsedStyle;
|
package/lib/camera/Camera.d.ts
CHANGED
|
@@ -18,8 +18,8 @@ export declare enum CAMERA_PROJECTION_MODE {
|
|
|
18
18
|
ORTHOGRAPHIC = "ORTHOGRAPHIC",
|
|
19
19
|
PERSPECTIVE = "PERSPECTIVE"
|
|
20
20
|
}
|
|
21
|
-
export declare const
|
|
22
|
-
|
|
21
|
+
export declare const CameraEvent: {
|
|
22
|
+
UPDATED: string;
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
25
|
* 参考「WebGL Insights - 23.Designing Cameras for WebGL Applications」,基于 Responsible Camera 思路设计
|
|
@@ -277,4 +277,5 @@ export declare class Camera extends EventEmitter {
|
|
|
277
277
|
*/
|
|
278
278
|
private _getDistance;
|
|
279
279
|
private _getOrthoMatrix;
|
|
280
|
+
private triggerUpdate;
|
|
280
281
|
}
|
package/lib/camera/Camera.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.DefaultCamera = exports.
|
|
6
|
+
exports.DefaultCamera = exports.CameraEvent = exports.Camera = exports.CAMERA_TYPE = exports.CAMERA_TRACKING_MODE = exports.CAMERA_PROJECTION_MODE = void 0;
|
|
7
7
|
|
|
8
8
|
var _tslib = require("tslib");
|
|
9
9
|
|
|
@@ -48,10 +48,10 @@ exports.CAMERA_PROJECTION_MODE = CAMERA_PROJECTION_MODE;
|
|
|
48
48
|
CAMERA_PROJECTION_MODE["PERSPECTIVE"] = "PERSPECTIVE";
|
|
49
49
|
})(CAMERA_PROJECTION_MODE || (exports.CAMERA_PROJECTION_MODE = CAMERA_PROJECTION_MODE = {}));
|
|
50
50
|
|
|
51
|
-
var
|
|
52
|
-
|
|
51
|
+
var CameraEvent = {
|
|
52
|
+
UPDATED: 'updated'
|
|
53
53
|
};
|
|
54
|
-
exports.
|
|
54
|
+
exports.CameraEvent = CameraEvent;
|
|
55
55
|
var DEG_2_RAD = Math.PI / 180;
|
|
56
56
|
var RAD_2_DEG = 180 / Math.PI;
|
|
57
57
|
/**
|
|
@@ -437,7 +437,7 @@ function (_super) {
|
|
|
437
437
|
|
|
438
438
|
_glMatrix.mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
|
|
439
439
|
|
|
440
|
-
this.
|
|
440
|
+
this.triggerUpdate();
|
|
441
441
|
return this;
|
|
442
442
|
};
|
|
443
443
|
|
|
@@ -476,7 +476,7 @@ function (_super) {
|
|
|
476
476
|
|
|
477
477
|
this._getOrthoMatrix();
|
|
478
478
|
|
|
479
|
-
this.
|
|
479
|
+
this.triggerUpdate();
|
|
480
480
|
return this;
|
|
481
481
|
};
|
|
482
482
|
/**
|
|
@@ -741,7 +741,7 @@ function (_super) {
|
|
|
741
741
|
|
|
742
742
|
this._setPosition(pos);
|
|
743
743
|
|
|
744
|
-
this.
|
|
744
|
+
this.triggerUpdate();
|
|
745
745
|
return this;
|
|
746
746
|
};
|
|
747
747
|
/**
|
|
@@ -772,7 +772,7 @@ function (_super) {
|
|
|
772
772
|
_glMatrix.vec3.add(this.focalPoint, pos, this.distanceVector);
|
|
773
773
|
}
|
|
774
774
|
|
|
775
|
-
this.
|
|
775
|
+
this.triggerUpdate();
|
|
776
776
|
return this;
|
|
777
777
|
};
|
|
778
778
|
|
|
@@ -853,7 +853,7 @@ function (_super) {
|
|
|
853
853
|
|
|
854
854
|
_this.computeMatrix();
|
|
855
855
|
|
|
856
|
-
_this.
|
|
856
|
+
_this.triggerUpdate();
|
|
857
857
|
|
|
858
858
|
var dist = _glMatrix.vec3.dist(interFocalPoint, destFocalPoint_1) + _glMatrix.vec3.dist(interPosition, destPosition_1);
|
|
859
859
|
|
|
@@ -895,7 +895,7 @@ function (_super) {
|
|
|
895
895
|
|
|
896
896
|
this._getOrthoMatrix();
|
|
897
897
|
|
|
898
|
-
this.
|
|
898
|
+
this.triggerUpdate();
|
|
899
899
|
};
|
|
900
900
|
/**
|
|
901
901
|
* 计算相机矩阵
|
|
@@ -1045,6 +1045,16 @@ function (_super) {
|
|
|
1045
1045
|
_glMatrix.mat4.fromRotationTranslationScaleOrigin(this.orthoMatrix, rotZ, _glMatrix.vec3.fromValues((this.rright - this.left) / 2 - position[0], (this.top - this.bottom) / 2 - position[1], 0), _glMatrix.vec3.fromValues(this.zoom, this.zoom, 1), position);
|
|
1046
1046
|
};
|
|
1047
1047
|
|
|
1048
|
+
Camera.prototype.triggerUpdate = function () {
|
|
1049
|
+
// update frustum
|
|
1050
|
+
var viewMatrix = this.getViewTransform();
|
|
1051
|
+
|
|
1052
|
+
var vpMatrix = _glMatrix.mat4.multiply(_glMatrix.mat4.create(), this.getPerspective(), viewMatrix);
|
|
1053
|
+
|
|
1054
|
+
this.getFrustum().extractFromVPMatrix(vpMatrix);
|
|
1055
|
+
this.emit(CameraEvent.UPDATED);
|
|
1056
|
+
};
|
|
1057
|
+
|
|
1048
1058
|
Camera.ProjectionMode = {
|
|
1049
1059
|
ORTHOGRAPHIC: 'ORTHOGRAPHIC',
|
|
1050
1060
|
PERSPECTIVE: 'PERSPECTIVE'
|
package/lib/canvas-module.js
CHANGED
|
@@ -19,6 +19,7 @@ var _services = require("./services");
|
|
|
19
19
|
|
|
20
20
|
var _EventPlugin = require("./plugins/EventPlugin");
|
|
21
21
|
|
|
22
|
+
// import { CSSCalculatorPlugin } from './plugins/CSSStyleCalculator';
|
|
22
23
|
var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
23
24
|
_manaSyringe.Contribution.register(register, _services.RenderingPluginContribution, {
|
|
24
25
|
cache: false
|
|
@@ -33,7 +34,8 @@ var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
|
33
34
|
register(_services.RenderingService);
|
|
34
35
|
register(_services.EventService);
|
|
35
36
|
register(_EventPlugin.EventPlugin);
|
|
36
|
-
register(_PrepareRendererPlugin.PrepareRendererPlugin);
|
|
37
|
+
register(_PrepareRendererPlugin.PrepareRendererPlugin); // register(CSSCalculatorPlugin);
|
|
38
|
+
|
|
37
39
|
register(_DirtyCheckPlugin.DirtyCheckPlugin);
|
|
38
40
|
register(_CullingPlugin.CullingPlugin);
|
|
39
41
|
register(_FrustumCullingStrategy.FrustumCullingStrategy);
|
|
@@ -10,5 +10,5 @@ export interface ParsedCircleStyleProps extends ParsedBaseStyleProps {
|
|
|
10
10
|
rInPixels: number;
|
|
11
11
|
}
|
|
12
12
|
export declare class Circle extends DisplayObject<CircleStyleProps, ParsedCircleStyleProps> {
|
|
13
|
-
constructor({ style, ...rest }
|
|
13
|
+
constructor({ style, ...rest }?: DisplayObjectConfig<CircleStyleProps>);
|
|
14
14
|
}
|
|
@@ -17,13 +17,18 @@ function (_super) {
|
|
|
17
17
|
(0, _tslib.__extends)(Circle, _super);
|
|
18
18
|
|
|
19
19
|
function Circle(_a) {
|
|
20
|
+
if (_a === void 0) {
|
|
21
|
+
_a = {};
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
var style = _a.style,
|
|
21
25
|
rest = (0, _tslib.__rest)(_a, ["style"]);
|
|
22
26
|
return _super.call(this, (0, _tslib.__assign)({
|
|
23
|
-
type: _types.
|
|
27
|
+
type: _types.Shape.CIRCLE,
|
|
24
28
|
style: (0, _tslib.__assign)({
|
|
25
29
|
r: 0,
|
|
26
|
-
anchor: [0.5, 0.5]
|
|
30
|
+
anchor: [0.5, 0.5],
|
|
31
|
+
lineWidth: 0
|
|
27
32
|
}, style)
|
|
28
33
|
}, rest)) || this;
|
|
29
34
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { DisplayObject } from './DisplayObject';
|
|
2
2
|
import type { DisplayObjectConfig } from '../dom/interfaces';
|
|
3
|
+
import type { BaseStyleProps } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* shadow root
|
|
5
6
|
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
6
7
|
*/
|
|
7
|
-
export declare abstract class CustomElement<CustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
8
|
-
constructor(config
|
|
8
|
+
export declare abstract class CustomElement<CustomElementStyleProps extends BaseStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
9
|
+
constructor(config?: DisplayObjectConfig<CustomElementStyleProps>);
|
|
9
10
|
/**
|
|
10
11
|
* fired after element insert into DOM tree
|
|
11
12
|
*/
|
|
@@ -21,6 +21,10 @@ function (_super) {
|
|
|
21
21
|
(0, _tslib.__extends)(CustomElement, _super); // private shadowNodes: DisplayObject[] = [];
|
|
22
22
|
|
|
23
23
|
function CustomElement(config) {
|
|
24
|
+
if (config === void 0) {
|
|
25
|
+
config = {};
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
var _this = _super.call(this, config) || this;
|
|
25
29
|
|
|
26
30
|
_this.handleMounted = function (e) {
|
|
@@ -64,20 +68,19 @@ function (_super) {
|
|
|
64
68
|
return;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
newValue = _a.newValue;
|
|
71
|
+
var attrName = e.attrName,
|
|
72
|
+
prevValue = e.prevValue,
|
|
73
|
+
newValue = e.newValue;
|
|
71
74
|
|
|
72
75
|
if (_this.attributeChangedCallback) {
|
|
73
|
-
_this.attributeChangedCallback(
|
|
76
|
+
_this.attributeChangedCallback(attrName, prevValue, newValue);
|
|
74
77
|
}
|
|
75
78
|
}; // this.addEventListener(ElementEvent.CHILD_INSERTED, this.handleChildInserted);
|
|
76
79
|
// this.addEventListener(ElementEvent.CHILD_REMOVED, this.handleChildRemoved);
|
|
77
80
|
|
|
78
81
|
|
|
79
82
|
if (_this.attributeChangedCallback) {
|
|
80
|
-
_this.addEventListener(_interfaces.ElementEvent.
|
|
83
|
+
_this.addEventListener(_interfaces.ElementEvent.ATTR_MODIFIED, _this.handleAttributeChanged);
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
if (_this.connectedCallback) {
|
|
@@ -35,14 +35,15 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
35
35
|
destroy(): void;
|
|
36
36
|
cloneNode(deep?: boolean): this;
|
|
37
37
|
private initAttributes;
|
|
38
|
-
setAttribute<Key extends keyof StyleProps>(
|
|
38
|
+
setAttribute<Key extends keyof StyleProps>(name: Key, value: StyleProps[Key], force?: boolean): void;
|
|
39
39
|
/**
|
|
40
40
|
* parse property, eg.
|
|
41
41
|
* * fill: 'red' => [1, 0, 0, 1]
|
|
42
42
|
* * translateX: '10px' => { unit: 'px', value: 10 }
|
|
43
|
+
* * fontSize: '2em' => { unit: 'px', value: 32 }
|
|
43
44
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
parseStyleProperty<Key extends keyof ParsedStyleProps>(name: Key, value: ParsedStyleProps[Key]): void;
|
|
46
|
+
updateStyleProperty<Key extends keyof ParsedStyleProps>(name: Key, oldParsedValue: ParsedStyleProps[Key], newParsedValue: ParsedStyleProps[Key]): void;
|
|
46
47
|
/**
|
|
47
48
|
* called when attributes get changed or initialized
|
|
48
49
|
*/
|