@antv/g 5.0.23-alpha.9 → 5.1.0
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 +4 -3
- package/es/AbstractRenderer.d.ts +11 -0
- package/es/AbstractRenderer.js +17 -2
- package/es/Canvas.d.ts +1 -1
- package/es/Canvas.js +2 -0
- package/es/css/CSS.d.ts +2 -1
- package/es/css/CSS.js +6 -2
- package/es/css/CSSProperty.d.ts +3 -2
- package/es/css/StyleValueRegistry.d.ts +4 -2
- package/es/css/StyleValueRegistry.js +100 -95
- package/es/css/cssom/CSSNumericValue.js +1 -1
- package/es/css/index.d.ts +2 -1
- package/es/css/index.js +2 -1
- package/es/css/interfaces.d.ts +6 -0
- package/es/css/interfaces.js +2 -0
- package/es/css/layout/FragmentResult.d.ts +32 -0
- package/es/css/layout/FragmentResult.js +32 -0
- package/es/css/layout/LayoutChildren.d.ts +23 -0
- package/es/css/layout/LayoutChildren.js +55 -0
- package/es/css/layout/LayoutContext.d.ts +35 -0
- package/es/css/layout/LayoutContext.js +35 -0
- package/es/css/layout/LayoutDefinition.d.ts +20 -0
- package/es/css/layout/LayoutDefinition.js +9 -0
- package/es/css/layout/LayoutEdges.d.ts +24 -0
- package/es/css/layout/LayoutEdges.js +41 -0
- package/es/css/layout/LayoutEngine.d.ts +41 -0
- package/es/css/layout/LayoutEngine.js +332 -0
- package/es/css/layout/LayoutFragment.d.ts +26 -0
- package/es/css/layout/LayoutFragment.js +28 -0
- package/es/css/layout/LayoutObject.d.ts +46 -0
- package/es/css/layout/LayoutObject.js +172 -0
- package/es/css/layout/LayoutRegistry.d.ts +16 -0
- package/es/css/layout/LayoutRegistry.js +78 -0
- package/es/css/layout/LayoutWorkTask.d.ts +14 -0
- package/es/css/layout/LayoutWorkTask.js +1 -0
- package/es/css/layout/index.d.ts +11 -0
- package/es/css/layout/index.js +11 -0
- package/es/css/layout/types.d.ts +104 -0
- package/es/css/layout/types.js +66 -0
- package/es/css/parser/color.d.ts +1 -1
- package/es/css/parser/color.js +2 -2
- package/es/css/parser/dimension.js +5 -1
- package/es/css/parser/path.d.ts +2 -2
- package/es/css/parser/path.js +9 -2
- package/es/css/parser/points.d.ts +8 -1
- package/es/css/parser/points.js +33 -3
- package/es/css/parser/transform.js +1 -1
- package/es/css/properties/CSSPropertyClipPath.js +7 -1
- package/es/css/properties/CSSPropertyColor.d.ts +1 -1
- package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
- package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
- package/es/css/properties/CSSPropertyLocalPosition.js +64 -20
- package/es/css/properties/CSSPropertyPath.d.ts +2 -2
- package/es/css/properties/CSSPropertyPath.js +7 -5
- package/es/css/properties/CSSPropertyPoints.js +3 -4
- package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
- package/es/css/properties/CSSPropertyTransform.js +76 -104
- package/es/display-objects/Circle.d.ts +4 -0
- package/es/display-objects/Circle.js +2 -0
- package/es/display-objects/DisplayObject.d.ts +2 -9
- package/es/display-objects/DisplayObject.js +8 -27
- package/es/display-objects/Ellipse.d.ts +4 -0
- package/es/display-objects/Ellipse.js +2 -0
- package/es/display-objects/Group.d.ts +4 -0
- package/es/display-objects/Group.js +2 -0
- package/es/display-objects/HTML.d.ts +4 -4
- package/es/display-objects/HTML.js +5 -3
- package/es/display-objects/Image.d.ts +4 -0
- package/es/display-objects/Image.js +2 -0
- package/es/display-objects/Line.js +2 -0
- package/es/display-objects/Path.d.ts +2 -2
- package/es/display-objects/Polygon.js +1 -1
- package/es/display-objects/Polyline.js +1 -1
- package/es/display-objects/Rect.d.ts +6 -2
- package/es/display-objects/Rect.js +2 -0
- package/es/display-objects/Text.d.ts +4 -0
- package/es/display-objects/Text.js +2 -0
- package/es/dom/Document.js +2 -2
- package/es/dom/Element.js +1 -0
- package/es/global-module.js +91 -8
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/plugins/CullingPlugin.d.ts +1 -0
- package/es/plugins/CullingPlugin.js +8 -3
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -0
- package/es/plugins/DirtyCheckPlugin.js +7 -2
- package/es/plugins/EventPlugin.d.ts +1 -0
- package/es/plugins/EventPlugin.js +14 -9
- package/es/plugins/PrepareRendererPlugin.d.ts +1 -0
- package/es/plugins/PrepareRendererPlugin.js +10 -5
- package/es/services/EventService.js +14 -10
- package/es/services/OffscreenCanvasCreator.d.ts +1 -1
- package/es/services/OffscreenCanvasCreator.js +1 -1
- package/es/services/RenderingService.d.ts +18 -18
- package/es/services/RenderingService.js +26 -23
- package/es/services/SceneGraphService.d.ts +2 -0
- package/es/services/SceneGraphService.js +12 -1
- package/es/services/aabb/CircleUpdater.d.ts +0 -2
- package/es/services/aabb/CircleUpdater.js +2 -6
- package/es/services/aabb/EllipseUpdater.d.ts +0 -2
- package/es/services/aabb/EllipseUpdater.js +2 -6
- package/es/services/aabb/LineUpdater.d.ts +0 -2
- package/es/services/aabb/LineUpdater.js +1 -3
- package/es/services/aabb/PathUpdater.d.ts +0 -2
- package/es/services/aabb/PathUpdater.js +1 -5
- package/es/services/aabb/PolylineUpdater.d.ts +0 -2
- package/es/services/aabb/PolylineUpdater.js +1 -3
- package/es/services/aabb/RectUpdater.d.ts +0 -2
- package/es/services/aabb/RectUpdater.js +1 -5
- package/es/services/aabb/TextUpdater.d.ts +7 -0
- package/es/services/aabb/TextUpdater.js +0 -4
- package/es/services/aabb/interfaces.d.ts +0 -3
- package/es/types.d.ts +12 -23
- package/es/types.js +1 -0
- package/es/utils/deferred.d.ts +43 -0
- package/es/utils/deferred.js +117 -0
- package/es/utils/dom.d.ts +2 -0
- package/es/utils/dom.js +8 -0
- package/es/utils/index.d.ts +2 -1
- package/es/utils/index.js +2 -1
- package/es/utils/interpolation.js +3 -9
- package/es/utils/math.js +4 -3
- package/es/utils/path.d.ts +2 -2
- package/es/utils/path.js +61 -24
- package/lib/AbstractRenderer.d.ts +11 -0
- package/lib/AbstractRenderer.js +17 -2
- package/lib/Canvas.d.ts +1 -1
- package/lib/Canvas.js +2 -0
- package/lib/css/CSS.d.ts +2 -1
- package/lib/css/CSS.js +9 -3
- package/lib/css/CSSProperty.d.ts +3 -2
- package/lib/css/StyleValueRegistry.d.ts +4 -2
- package/lib/css/StyleValueRegistry.js +104 -96
- package/lib/css/cssom/CSSNumericValue.js +17 -17
- package/lib/css/index.d.ts +2 -1
- package/lib/css/index.js +25 -12
- package/lib/css/interfaces.d.ts +6 -0
- package/lib/css/interfaces.js +12 -0
- package/lib/css/layout/FragmentResult.d.ts +32 -0
- package/lib/css/layout/FragmentResult.js +51 -0
- package/lib/css/layout/LayoutChildren.d.ts +23 -0
- package/lib/css/layout/LayoutChildren.js +72 -0
- package/lib/css/layout/LayoutContext.d.ts +35 -0
- package/lib/css/layout/LayoutContext.js +49 -0
- package/lib/css/layout/LayoutDefinition.d.ts +20 -0
- package/lib/css/layout/LayoutDefinition.js +16 -0
- package/lib/css/layout/LayoutEdges.d.ts +24 -0
- package/lib/css/layout/LayoutEdges.js +56 -0
- package/lib/css/layout/LayoutEngine.d.ts +41 -0
- package/lib/css/layout/LayoutEngine.js +345 -0
- package/lib/css/layout/LayoutFragment.d.ts +26 -0
- package/lib/css/layout/LayoutFragment.js +44 -0
- package/lib/css/layout/LayoutObject.d.ts +46 -0
- package/lib/css/layout/LayoutObject.js +182 -0
- package/lib/css/layout/LayoutRegistry.d.ts +16 -0
- package/lib/css/layout/LayoutRegistry.js +87 -0
- package/lib/css/layout/LayoutWorkTask.d.ts +14 -0
- package/lib/css/layout/LayoutWorkTask.js +5 -0
- package/lib/css/layout/index.d.ts +11 -0
- package/lib/css/layout/index.js +148 -0
- package/lib/css/layout/types.d.ts +104 -0
- package/lib/css/layout/types.js +74 -0
- package/lib/css/parser/color.d.ts +1 -1
- package/lib/css/parser/color.js +1 -1
- package/lib/css/parser/dimension.js +4 -0
- package/lib/css/parser/path.d.ts +2 -2
- package/lib/css/parser/path.js +9 -2
- package/lib/css/parser/points.d.ts +8 -1
- package/lib/css/parser/points.js +33 -3
- package/lib/css/parser/transform.js +1 -1
- package/lib/css/properties/CSSPropertyClipPath.js +8 -1
- package/lib/css/properties/CSSPropertyColor.d.ts +1 -1
- package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
- package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
- package/lib/css/properties/CSSPropertyLocalPosition.js +65 -20
- package/lib/css/properties/CSSPropertyPath.d.ts +2 -2
- package/lib/css/properties/CSSPropertyPath.js +7 -5
- package/lib/css/properties/CSSPropertyPoints.js +3 -4
- package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
- package/lib/css/properties/CSSPropertyTransform.js +75 -103
- package/lib/display-objects/Circle.d.ts +4 -0
- package/lib/display-objects/Circle.js +2 -0
- package/lib/display-objects/DisplayObject.d.ts +2 -9
- package/lib/display-objects/DisplayObject.js +9 -29
- package/lib/display-objects/Ellipse.d.ts +4 -0
- package/lib/display-objects/Ellipse.js +2 -0
- package/lib/display-objects/Group.d.ts +4 -0
- package/lib/display-objects/Group.js +2 -0
- package/lib/display-objects/HTML.d.ts +4 -4
- package/lib/display-objects/HTML.js +5 -3
- package/lib/display-objects/Image.d.ts +4 -0
- package/lib/display-objects/Image.js +2 -0
- package/lib/display-objects/Line.js +2 -0
- package/lib/display-objects/Path.d.ts +2 -2
- package/lib/display-objects/Polygon.js +1 -1
- package/lib/display-objects/Polyline.js +1 -1
- package/lib/display-objects/Rect.d.ts +6 -2
- package/lib/display-objects/Rect.js +2 -0
- package/lib/display-objects/Text.d.ts +4 -0
- package/lib/display-objects/Text.js +2 -0
- package/lib/dom/Document.js +2 -2
- package/lib/dom/Element.js +1 -0
- package/lib/global-module.js +91 -6
- package/lib/index.d.ts +3 -0
- package/lib/index.js +7 -2
- package/lib/plugins/CullingPlugin.d.ts +1 -0
- package/lib/plugins/CullingPlugin.js +7 -3
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -0
- package/lib/plugins/DirtyCheckPlugin.js +6 -2
- package/lib/plugins/EventPlugin.d.ts +1 -0
- package/lib/plugins/EventPlugin.js +13 -9
- package/lib/plugins/PrepareRendererPlugin.d.ts +1 -0
- package/lib/plugins/PrepareRendererPlugin.js +9 -5
- package/lib/services/EventService.js +14 -10
- package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
- package/lib/services/OffscreenCanvasCreator.js +1 -1
- package/lib/services/RenderingService.d.ts +18 -18
- package/lib/services/RenderingService.js +26 -23
- package/lib/services/SceneGraphService.d.ts +2 -0
- package/lib/services/SceneGraphService.js +15 -1
- package/lib/services/aabb/CircleUpdater.d.ts +0 -2
- package/lib/services/aabb/CircleUpdater.js +2 -6
- package/lib/services/aabb/EllipseUpdater.d.ts +0 -2
- package/lib/services/aabb/EllipseUpdater.js +2 -6
- package/lib/services/aabb/LineUpdater.d.ts +0 -2
- package/lib/services/aabb/LineUpdater.js +1 -3
- package/lib/services/aabb/PathUpdater.d.ts +0 -2
- package/lib/services/aabb/PathUpdater.js +1 -5
- package/lib/services/aabb/PolylineUpdater.d.ts +0 -2
- package/lib/services/aabb/PolylineUpdater.js +1 -3
- package/lib/services/aabb/RectUpdater.d.ts +0 -2
- package/lib/services/aabb/RectUpdater.js +1 -5
- package/lib/services/aabb/TextUpdater.d.ts +7 -0
- package/lib/services/aabb/TextUpdater.js +0 -4
- package/lib/services/aabb/interfaces.d.ts +0 -3
- package/lib/types.d.ts +12 -23
- package/lib/types.js +1 -0
- package/lib/utils/deferred.d.ts +43 -0
- package/lib/utils/deferred.js +131 -0
- package/lib/utils/dom.d.ts +2 -0
- package/lib/utils/dom.js +17 -0
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +17 -4
- package/lib/utils/interpolation.js +4 -10
- package/lib/utils/math.js +4 -3
- package/lib/utils/path.d.ts +2 -2
- package/lib/utils/path.js +55 -24
- package/package.json +4 -3
- package/es/css/LayoutRegistry.d.ts +0 -11
- package/es/css/LayoutRegistry.js +0 -22
- package/es/utils/hooks.d.ts +0 -280
- package/es/utils/hooks.js +0 -753
- package/lib/css/LayoutRegistry.d.ts +0 -11
- package/lib/css/LayoutRegistry.js +0 -30
- package/lib/utils/hooks.d.ts +0 -280
- package/lib/utils/hooks.js +0 -759
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { __values } from "tslib";
|
|
2
|
+
/**
|
|
3
|
+
* This function allow you to modify a JS Promise by adding some status properties.
|
|
4
|
+
* Based on: http://stackoverflow.com/questions/21485545/is-there-a-way-to-tell-if-an-es6-promise-is-fulfilled-rejected-resolved
|
|
5
|
+
* But modified according to the specs of promises : https://promisesaplus.com/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export var makeQuerablePromise = function makeQuerablePromise(promise) {
|
|
9
|
+
// Don't modify any promise that has been already modified.
|
|
10
|
+
if (promise.isRejected || promise.isFulfilled) return promise; // Set initial state
|
|
11
|
+
|
|
12
|
+
var isPending = true;
|
|
13
|
+
var isRejected = false;
|
|
14
|
+
var isFulfilled = false;
|
|
15
|
+
var fullFilledValue; // Observe the promise, saving the fulfillment in a closure scope.
|
|
16
|
+
|
|
17
|
+
var result = promise.then(function (v) {
|
|
18
|
+
isFulfilled = true;
|
|
19
|
+
isPending = false;
|
|
20
|
+
fullFilledValue = v;
|
|
21
|
+
return v;
|
|
22
|
+
}, function (e) {
|
|
23
|
+
isRejected = true;
|
|
24
|
+
isPending = false;
|
|
25
|
+
throw e;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
result.isFulfilled = function () {
|
|
29
|
+
return isFulfilled;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
result.isPending = function () {
|
|
33
|
+
return isPending;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
result.isRejected = function () {
|
|
37
|
+
return isRejected;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
result.getFullFilledValue = function () {
|
|
41
|
+
return fullFilledValue;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Simple implementation of the deferred pattern.
|
|
48
|
+
* An object that exposes a promise and functions to resolve and reject it.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
var Deferred =
|
|
52
|
+
/** @class */
|
|
53
|
+
function () {
|
|
54
|
+
function Deferred() {
|
|
55
|
+
var _this = this;
|
|
56
|
+
|
|
57
|
+
this.promise = new Promise(function (resolve, reject) {
|
|
58
|
+
_this.resolve = resolve;
|
|
59
|
+
_this.reject = reject;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return Deferred;
|
|
64
|
+
}();
|
|
65
|
+
|
|
66
|
+
export { Deferred };
|
|
67
|
+
export var equalSet = function equalSet(as, bs) {
|
|
68
|
+
var e_1, _a;
|
|
69
|
+
|
|
70
|
+
if (as.size !== bs.size) return false;
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
74
|
+
for (var as_1 = __values(as), as_1_1 = as_1.next(); !as_1_1.done; as_1_1 = as_1.next()) {
|
|
75
|
+
var a = as_1_1.value;
|
|
76
|
+
|
|
77
|
+
if (!bs.has(a)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} catch (e_1_1) {
|
|
82
|
+
e_1 = {
|
|
83
|
+
error: e_1_1
|
|
84
|
+
};
|
|
85
|
+
} finally {
|
|
86
|
+
try {
|
|
87
|
+
if (as_1_1 && !as_1_1.done && (_a = as_1.return)) _a.call(as_1);
|
|
88
|
+
} finally {
|
|
89
|
+
if (e_1) throw e_1.error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return true;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Nicely typed aliases for some `Object` Methods
|
|
97
|
+
* - PSA: Don't mutate `yourObject`s
|
|
98
|
+
* - Numerical keys are BAD, resolve that issue upstream
|
|
99
|
+
* - Discussion: https://stackoverflow.com/a/65117465/565877
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
export var ObjectTyped = {
|
|
103
|
+
/**
|
|
104
|
+
* Object.keys, but with nice typing (`Array<keyof T>`)
|
|
105
|
+
*/
|
|
106
|
+
keys: Object.keys,
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Object.values, but with nice typing
|
|
110
|
+
*/
|
|
111
|
+
values: Object.values,
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Object.entries, but with nice typing
|
|
115
|
+
*/
|
|
116
|
+
entries: Object.entries
|
|
117
|
+
};
|
package/es/utils/dom.js
ADDED
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
2
|
import { GlobalContainer } from 'mana-syringe';
|
|
3
|
-
import { StyleValueRegistry } from '../css';
|
|
3
|
+
import { StyleValueRegistry } from '../css/interfaces';
|
|
4
4
|
import { parseEasingFunction } from './animation';
|
|
5
5
|
import { camelCase } from './string';
|
|
6
6
|
export function convertEffectInput(keyframes, timing, target) {
|
|
@@ -121,8 +121,8 @@ function propertyInterpolation(property, left, right, target) {
|
|
|
121
121
|
|
|
122
122
|
if (propertyHandler) {
|
|
123
123
|
if (propertyHandler.parser) {
|
|
124
|
-
parsedLeft = propertyHandler.parser(left);
|
|
125
|
-
parsedRight = propertyHandler.parser(right);
|
|
124
|
+
parsedLeft = propertyHandler.parser(left, target);
|
|
125
|
+
parsedRight = propertyHandler.parser(right, target);
|
|
126
126
|
} // if (propertyHandler.calculator) {
|
|
127
127
|
// parsedLeft = propertyHandler.calculator(parsedLeft);
|
|
128
128
|
// // parsedLeft = handler.calculator
|
|
@@ -184,12 +184,6 @@ var FORMAT_ATTR_MAP = {
|
|
|
184
184
|
d: {
|
|
185
185
|
alias: 'path'
|
|
186
186
|
},
|
|
187
|
-
cx: {
|
|
188
|
-
alias: 'x'
|
|
189
|
-
},
|
|
190
|
-
cy: {
|
|
191
|
-
alias: 'y'
|
|
192
|
-
},
|
|
193
187
|
strokeDasharray: {
|
|
194
188
|
alias: 'lineDash'
|
|
195
189
|
},
|
package/es/utils/math.js
CHANGED
|
@@ -199,8 +199,8 @@ export function makePerspective(out, left, right, top, bottom, near, far) {
|
|
|
199
199
|
}
|
|
200
200
|
export function decompose(mat) {
|
|
201
201
|
var row0x = mat[0];
|
|
202
|
-
var row0y = mat[
|
|
203
|
-
var row1x = mat[
|
|
202
|
+
var row0y = mat[1];
|
|
203
|
+
var row1x = mat[3];
|
|
204
204
|
var row1y = mat[4]; // decompose 3x3 matrix
|
|
205
205
|
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
206
206
|
|
|
@@ -230,6 +230,7 @@ export function decompose(mat) {
|
|
|
230
230
|
} // Compute rotation and renormalize matrix.
|
|
231
231
|
|
|
232
232
|
|
|
233
|
-
var
|
|
233
|
+
var rotation = Math.atan2(row0y, row0x);
|
|
234
|
+
var angle = rad2deg(rotation);
|
|
234
235
|
return [mat[6], mat[7], scalingX, scalingY, angle];
|
|
235
236
|
}
|
package/es/utils/path.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Circle, Ellipse, Line, Path, Polyline, Polygon, Rect } from '../display-objects';
|
|
2
2
|
import type { PathCommand } from '../types';
|
|
3
3
|
export declare function equalizeSegments(path1: PathCommand[], path2: PathCommand[], TL?: number): PathCommand[][];
|
|
4
4
|
export declare function getDrawDirection(pathArray: PathCommand[]): boolean;
|
|
@@ -12,4 +12,4 @@ export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (st
|
|
|
12
12
|
* * anchor
|
|
13
13
|
* * lineWidth
|
|
14
14
|
*/
|
|
15
|
-
export declare function convertToPath(object:
|
|
15
|
+
export declare function convertToPath(object: Circle | Ellipse | Rect | Line | Polyline | Polygon | Path, applyLocalTransform?: boolean): string;
|
package/es/utils/path.js
CHANGED
|
@@ -205,17 +205,32 @@ export function getRotatedCurve(a, b) {
|
|
|
205
205
|
return rotations[computedIndex];
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
function commandsToPathString(commands,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
function commandsToPathString(commands, object, applyLocalTransform) {
|
|
209
|
+
if (applyLocalTransform === void 0) {
|
|
210
|
+
applyLocalTransform = true;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
var transform;
|
|
214
|
+
|
|
215
|
+
if (applyLocalTransform) {
|
|
216
|
+
transform = object.getLocalTransform();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
var _a = object.parsedStyle,
|
|
220
|
+
_b = _a.defX,
|
|
221
|
+
defX = _b === void 0 ? 0 : _b,
|
|
222
|
+
_c = _a.defY,
|
|
223
|
+
defY = _c === void 0 ? 0 : _c;
|
|
213
224
|
return commands.reduce(function (prev, cur) {
|
|
214
225
|
var path = '';
|
|
215
226
|
|
|
216
227
|
if (cur[0] === 'M' || cur[0] === 'L') {
|
|
217
228
|
var p = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
|
|
218
|
-
|
|
229
|
+
|
|
230
|
+
if (applyLocalTransform) {
|
|
231
|
+
vec3.transformMat4(p, p, transform);
|
|
232
|
+
}
|
|
233
|
+
|
|
219
234
|
path = "".concat(cur[0]).concat(p[0], ",").concat(p[1]);
|
|
220
235
|
} else if (cur[0] === 'Z') {
|
|
221
236
|
path = cur[0];
|
|
@@ -223,13 +238,21 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
|
|
|
223
238
|
var p1 = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
|
|
224
239
|
var p2 = vec3.fromValues(cur[3] - defX, cur[4] - defY, 0);
|
|
225
240
|
var p3 = vec3.fromValues(cur[5] - defX, cur[6] - defY, 0);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
241
|
+
|
|
242
|
+
if (applyLocalTransform) {
|
|
243
|
+
vec3.transformMat4(p1, p1, transform);
|
|
244
|
+
vec3.transformMat4(p2, p2, transform);
|
|
245
|
+
vec3.transformMat4(p3, p3, transform);
|
|
246
|
+
}
|
|
247
|
+
|
|
229
248
|
path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
|
|
230
249
|
} else if (cur[0] === 'A') {
|
|
231
250
|
var c = vec3.fromValues(cur[6] - defX, cur[7] - defY, 0);
|
|
232
|
-
|
|
251
|
+
|
|
252
|
+
if (applyLocalTransform) {
|
|
253
|
+
vec3.transformMat4(c, c, transform);
|
|
254
|
+
}
|
|
255
|
+
|
|
233
256
|
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]);
|
|
234
257
|
}
|
|
235
258
|
|
|
@@ -252,10 +275,16 @@ function ellipseToCommands(rx, ry, cx, cy) {
|
|
|
252
275
|
return [['M', left, cy], ['C', left, cy - dy, cx - dx, top, cx, top], ['C', cx + dx, top, right, cy - dy, right, cy], ['C', right, cy + dy, cx + dx, bottom, cx, bottom], ['C', cx - dx, bottom, left, cy + dy, left, cy], ['Z']];
|
|
253
276
|
}
|
|
254
277
|
|
|
255
|
-
function polygonToCommands(points) {
|
|
256
|
-
|
|
278
|
+
function polygonToCommands(points, closed) {
|
|
279
|
+
var result = points.map(function (point, i) {
|
|
257
280
|
return [i === 0 ? 'M' : 'L', point[0], point[1]];
|
|
258
281
|
});
|
|
282
|
+
|
|
283
|
+
if (closed) {
|
|
284
|
+
result.push(['Z']);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return result;
|
|
259
288
|
}
|
|
260
289
|
|
|
261
290
|
function rectToCommands(width, height, x, y, radius) {
|
|
@@ -274,9 +303,11 @@ function rectToCommands(width, height, x, y, radius) {
|
|
|
274
303
|
*/
|
|
275
304
|
|
|
276
305
|
|
|
277
|
-
export function convertToPath(object) {
|
|
278
|
-
|
|
279
|
-
|
|
306
|
+
export function convertToPath(object, applyLocalTransform) {
|
|
307
|
+
if (applyLocalTransform === void 0) {
|
|
308
|
+
applyLocalTransform = true;
|
|
309
|
+
}
|
|
310
|
+
|
|
280
311
|
var commands = [];
|
|
281
312
|
|
|
282
313
|
switch (object.nodeName) {
|
|
@@ -293,9 +324,9 @@ export function convertToPath(object) {
|
|
|
293
324
|
{
|
|
294
325
|
var _b = object.parsedStyle,
|
|
295
326
|
r = _b.r,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
commands = ellipseToCommands(r.value, r.value,
|
|
327
|
+
cx = _b.cx,
|
|
328
|
+
cy = _b.cy;
|
|
329
|
+
commands = ellipseToCommands(r.value, r.value, cx.value, cy.value);
|
|
299
330
|
break;
|
|
300
331
|
}
|
|
301
332
|
|
|
@@ -304,16 +335,16 @@ export function convertToPath(object) {
|
|
|
304
335
|
var _c = object.parsedStyle,
|
|
305
336
|
rx = _c.rx,
|
|
306
337
|
ry = _c.ry,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
commands = ellipseToCommands(rx.value, ry.value,
|
|
338
|
+
cx = _c.cx,
|
|
339
|
+
cy = _c.cy;
|
|
340
|
+
commands = ellipseToCommands(rx.value, ry.value, cx.value, cy.value);
|
|
310
341
|
break;
|
|
311
342
|
}
|
|
312
343
|
|
|
313
344
|
case Shape.POLYLINE:
|
|
314
345
|
case Shape.POLYGON:
|
|
315
346
|
var points = object.parsedStyle.points;
|
|
316
|
-
commands = polygonToCommands(points.points);
|
|
347
|
+
commands = polygonToCommands(points.points, object.nodeName === Shape.POLYGON);
|
|
317
348
|
break;
|
|
318
349
|
|
|
319
350
|
case Shape.RECT:
|
|
@@ -327,11 +358,17 @@ export function convertToPath(object) {
|
|
|
327
358
|
break;
|
|
328
359
|
|
|
329
360
|
case Shape.PATH:
|
|
330
|
-
|
|
361
|
+
var _e = object.parsedStyle.path,
|
|
362
|
+
curve = _e.curve,
|
|
363
|
+
zCommandIndexes = _e.zCommandIndexes;
|
|
364
|
+
commands = __spreadArray([], __read(curve), false);
|
|
365
|
+
zCommandIndexes.forEach(function (zIndex, index) {
|
|
366
|
+
commands.splice(zIndex + index, 1, ['Z']);
|
|
367
|
+
});
|
|
331
368
|
break;
|
|
332
369
|
}
|
|
333
370
|
|
|
334
371
|
if (commands.length) {
|
|
335
|
-
return commandsToPathString(commands,
|
|
372
|
+
return commandsToPathString(commands, object, applyLocalTransform);
|
|
336
373
|
}
|
|
337
374
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Syringe } from 'mana-syringe';
|
|
2
2
|
import type { RendererConfig } from './types';
|
|
3
3
|
export interface RendererPlugin {
|
|
4
|
+
name: string;
|
|
4
5
|
init: (container: Syringe.Container) => void;
|
|
5
6
|
destroy: (container: Syringe.Container) => void;
|
|
6
7
|
}
|
|
@@ -10,6 +11,14 @@ export interface IRenderer {
|
|
|
10
11
|
* register plugin at runtime
|
|
11
12
|
*/
|
|
12
13
|
registerPlugin: (plugin: RendererPlugin) => void;
|
|
14
|
+
/**
|
|
15
|
+
* unregister plugin at runtime
|
|
16
|
+
*/
|
|
17
|
+
unregisterPlugin: (plugin: RendererPlugin) => void;
|
|
18
|
+
/**
|
|
19
|
+
* get plugin by name
|
|
20
|
+
*/
|
|
21
|
+
getPlugin: (name: string) => RendererPlugin;
|
|
13
22
|
/**
|
|
14
23
|
* return all registered plugins
|
|
15
24
|
*/
|
|
@@ -20,7 +29,9 @@ export declare class AbstractRenderer implements IRenderer {
|
|
|
20
29
|
private config;
|
|
21
30
|
constructor(config?: Partial<RendererConfig>);
|
|
22
31
|
registerPlugin(plugin: RendererPlugin): void;
|
|
32
|
+
unregisterPlugin(plugin: RendererPlugin): void;
|
|
23
33
|
getPlugins(): RendererPlugin[];
|
|
34
|
+
getPlugin(name: string): RendererPlugin;
|
|
24
35
|
getConfig(): RendererConfig;
|
|
25
36
|
setConfig(config: Partial<RendererConfig>): void;
|
|
26
37
|
}
|
package/lib/AbstractRenderer.js
CHANGED
|
@@ -27,8 +27,7 @@ function () {
|
|
|
27
27
|
* enable dirty rectangle rendering by default
|
|
28
28
|
*/
|
|
29
29
|
enableDirtyRectangleRendering: true,
|
|
30
|
-
enableDirtyRectangleRenderingDebug: false
|
|
31
|
-
enableTAA: false
|
|
30
|
+
enableDirtyRectangleRenderingDebug: false
|
|
32
31
|
}, config);
|
|
33
32
|
}
|
|
34
33
|
|
|
@@ -36,10 +35,26 @@ function () {
|
|
|
36
35
|
this.plugins.push(plugin);
|
|
37
36
|
};
|
|
38
37
|
|
|
38
|
+
AbstractRenderer.prototype.unregisterPlugin = function (plugin) {
|
|
39
|
+
var index = this.plugins.findIndex(function (p) {
|
|
40
|
+
return p === plugin;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (index > -1) {
|
|
44
|
+
this.plugins.splice(index, 1);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
39
48
|
AbstractRenderer.prototype.getPlugins = function () {
|
|
40
49
|
return this.plugins;
|
|
41
50
|
};
|
|
42
51
|
|
|
52
|
+
AbstractRenderer.prototype.getPlugin = function (name) {
|
|
53
|
+
return this.plugins.find(function (plugin) {
|
|
54
|
+
return plugin.name === name;
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
43
58
|
AbstractRenderer.prototype.getConfig = function () {
|
|
44
59
|
return this.config;
|
|
45
60
|
};
|
package/lib/Canvas.d.ts
CHANGED
|
@@ -96,7 +96,7 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
96
96
|
* get the root displayObject in scenegraph
|
|
97
97
|
* @alias this.document.documentElement
|
|
98
98
|
*/
|
|
99
|
-
getRoot(): import("
|
|
99
|
+
getRoot(): import(".").Group;
|
|
100
100
|
/**
|
|
101
101
|
* get the camera of canvas
|
|
102
102
|
*/
|
package/lib/Canvas.js
CHANGED
|
@@ -116,6 +116,8 @@ function (_super) {
|
|
|
116
116
|
/**
|
|
117
117
|
* limits query
|
|
118
118
|
*/
|
|
119
|
+
// the following feature-detect from hammer.js
|
|
120
|
+
// @see https://github.com/hammerjs/hammer.js/blob/master/src/inputjs/input-consts.js#L5
|
|
119
121
|
|
|
120
122
|
_this.supportTouchEvent = supportTouchEvent !== null && supportTouchEvent !== void 0 ? supportTouchEvent : 'ontouchstart' in globalThis;
|
|
121
123
|
_this.supportPointerEvent = supportPointerEvent !== null && supportPointerEvent !== void 0 ? supportPointerEvent : !!globalThis.PointerEvent;
|
package/lib/css/CSS.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CSSUnitValue } from './cssom';
|
|
2
|
+
import type { LayoutDefinitionCtor } from './layout';
|
|
2
3
|
/**
|
|
3
4
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty#parameters
|
|
4
5
|
*/
|
|
@@ -80,5 +81,5 @@ export declare const CSS: {
|
|
|
80
81
|
* @see https://github.com/w3c/css-houdini-drafts/blob/main/css-layout-api/EXPLAINER.md
|
|
81
82
|
* @see https://developer.mozilla.org/en-US/docs/Web/Guide/Houdini#css_layout_api
|
|
82
83
|
*/
|
|
83
|
-
registerLayout: (name: string) => void;
|
|
84
|
+
registerLayout: (name: string, clazz: LayoutDefinitionCtor) => void;
|
|
84
85
|
};
|
package/lib/css/CSS.js
CHANGED
|
@@ -9,7 +9,9 @@ var _manaSyringe = require("mana-syringe");
|
|
|
9
9
|
|
|
10
10
|
var _cssom = require("./cssom");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _interfaces = require("./interfaces");
|
|
13
|
+
|
|
14
|
+
var _layout = require("./layout");
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* holds useful CSS-related methods.
|
|
@@ -104,7 +106,7 @@ var CSS = {
|
|
|
104
106
|
inherits = definition.inherits,
|
|
105
107
|
initialValue = definition.initialValue;
|
|
106
108
|
|
|
107
|
-
var registry = _manaSyringe.GlobalContainer.get(
|
|
109
|
+
var registry = _manaSyringe.GlobalContainer.get(_interfaces.StyleValueRegistry);
|
|
108
110
|
|
|
109
111
|
registry.registerMetadata({
|
|
110
112
|
name: name,
|
|
@@ -120,6 +122,10 @@ var CSS = {
|
|
|
120
122
|
* @see https://github.com/w3c/css-houdini-drafts/blob/main/css-layout-api/EXPLAINER.md
|
|
121
123
|
* @see https://developer.mozilla.org/en-US/docs/Web/Guide/Houdini#css_layout_api
|
|
122
124
|
*/
|
|
123
|
-
registerLayout: function registerLayout(name) {
|
|
125
|
+
registerLayout: function registerLayout(name, clazz) {
|
|
126
|
+
var layoutRegistry = _manaSyringe.GlobalContainer.get(_layout.LayoutRegistry);
|
|
127
|
+
|
|
128
|
+
layoutRegistry.registerLayout(name, clazz);
|
|
129
|
+
}
|
|
124
130
|
};
|
|
125
131
|
exports.CSS = CSS;
|
package/lib/css/CSSProperty.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { DisplayObject } from '../display-objects';
|
|
1
2
|
import type { IElement } from '../dom';
|
|
2
|
-
import type { StyleValueRegistry } from './
|
|
3
|
+
import type { StyleValueRegistry } from './interfaces';
|
|
3
4
|
export declare type Interpolatable = number | boolean | number[] | boolean[];
|
|
4
5
|
declare type CSSPropertyMixer<Parsed = any, T extends Interpolatable = any> = (left: Parsed, right: Parsed, displayObject: IElement | null) => [T, T, (i: T) => string | any] | undefined;
|
|
5
|
-
declare type CSSPropertyParser<Parsed> = (value: string | any) => Parsed;
|
|
6
|
+
declare type CSSPropertyParser<Parsed> = (value: string | any, object: DisplayObject) => Parsed;
|
|
6
7
|
declare type CSSPropertyCalculator<Parsed, Used> = (name: string, oldParsed: Parsed, parsed: Parsed, object: IElement, registry: StyleValueRegistry) => Used;
|
|
7
8
|
/**
|
|
8
9
|
* 1. parser: raw CSS string -> Computed Value
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DisplayObject } from '../display-objects';
|
|
2
2
|
import type { BaseStyleProps } from '../types';
|
|
3
3
|
import { CSSStyleValue } from './cssom';
|
|
4
|
+
import { StyleValueRegistry } from './interfaces';
|
|
4
5
|
export declare type CSSGlobalKeywords = 'unset' | 'initial' | 'inherit' | '';
|
|
5
6
|
export interface PropertyParseOptions {
|
|
6
7
|
skipUpdateAttribute: boolean;
|
|
@@ -13,6 +14,7 @@ export declare const PropertySyntax: {
|
|
|
13
14
|
LENGTH: string;
|
|
14
15
|
PERCENTAGE: string;
|
|
15
16
|
LENGTH_PERCENTAGE: string;
|
|
17
|
+
LIST_OF_POINTS: string;
|
|
16
18
|
};
|
|
17
19
|
export interface PropertyMetadata {
|
|
18
20
|
name: string;
|
|
@@ -65,7 +67,7 @@ export interface PropertyMetadata {
|
|
|
65
67
|
* Blink used them in code generation(css_properties.json5)
|
|
66
68
|
*/
|
|
67
69
|
export declare const BUILT_IN_PROPERTIES: PropertyMetadata[];
|
|
68
|
-
export declare class StyleValueRegistry {
|
|
70
|
+
export declare class DefaultStyleValueRegistry implements StyleValueRegistry {
|
|
69
71
|
/**
|
|
70
72
|
* need recalc later
|
|
71
73
|
*/
|
|
@@ -98,7 +100,7 @@ export declare class StyleValueRegistry {
|
|
|
98
100
|
/**
|
|
99
101
|
* string -> parsed value
|
|
100
102
|
*/
|
|
101
|
-
parseProperty(name: string, value: any): CSSStyleValue;
|
|
103
|
+
parseProperty(name: string, value: any, object: DisplayObject): CSSStyleValue;
|
|
102
104
|
/**
|
|
103
105
|
* computed value -> used value
|
|
104
106
|
*/
|