@antv/g 5.0.22 → 5.0.23-alpha.11
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 +3 -3
- package/es/AbstractRenderer.js +5 -0
- package/es/camera/Camera.js +2 -2
- package/es/css/StyleValueRegistry.d.ts +2 -0
- package/es/css/StyleValueRegistry.js +7 -3
- package/es/css/cssom/CSSKeywordValue.d.ts +1 -1
- package/es/css/cssom/CSSNumericSumValue.d.ts +1 -1
- package/es/css/cssom/CSSNumericValue.d.ts +141 -4
- package/es/css/cssom/CSSNumericValue.js +1166 -5
- package/es/css/cssom/CSSTransformValue.d.ts +1 -1
- package/es/css/cssom/index.d.ts +0 -10
- package/es/css/cssom/index.js +1 -11
- package/es/css/parser/color.js +1 -1
- package/es/css/parser/dimension.js +1 -2
- package/es/css/parser/numeric.d.ts +1 -1
- package/es/css/parser/numeric.js +2 -2
- package/es/css/parser/path.d.ts +2 -2
- package/es/css/parser/path.js +1 -1
- package/es/css/parser/points.js +1 -1
- package/es/css/parser/transform-origin.d.ts +1 -1
- package/es/css/parser/transform-origin.js +2 -2
- package/es/css/parser/transform.d.ts +1 -3
- package/es/css/parser/transform.js +9 -8
- package/es/css/properties/CSSPropertyPath.d.ts +14 -2
- package/es/css/properties/CSSPropertyTextTransform.d.ts +2 -2
- package/es/css/properties/CSSPropertyTransform.js +3 -4
- package/es/display-objects/DisplayObject.js +4 -5
- package/es/display-objects/Path.d.ts +15 -15
- package/es/display-objects/Path.js +1 -1
- package/es/display-objects/Polygon.d.ts +8 -1
- package/es/display-objects/Polyline.d.ts +7 -5
- package/es/dom/Document.js +2 -2
- package/es/dom/Element.js +1 -2
- package/es/dom/EventTarget.js +1 -1
- package/es/dom/FederatedTouchEvent.d.ts +5 -3
- package/es/plugins/CullingPlugin.d.ts +0 -1
- package/es/plugins/CullingPlugin.js +3 -8
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/es/plugins/DirtyCheckPlugin.js +9 -8
- package/es/plugins/EventPlugin.d.ts +1 -1
- package/es/plugins/EventPlugin.js +163 -148
- package/es/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/es/plugins/PrepareRendererPlugin.js +17 -18
- package/es/services/EventService.d.ts +8 -0
- package/es/services/EventService.js +274 -20
- package/es/services/RenderingService.d.ts +17 -16
- package/es/services/RenderingService.js +20 -19
- package/es/services/SceneGraphService.js +1 -1
- package/es/services/aabb/PathUpdater.d.ts +3 -3
- package/es/services/aabb/PolylineUpdater.d.ts +3 -3
- package/es/services/aabb/RectUpdater.js +1 -1
- package/es/types.d.ts +5 -3
- package/es/utils/assert.d.ts +6 -0
- package/es/utils/assert.js +18 -0
- package/es/utils/event.d.ts +18 -16
- package/es/utils/hooks.d.ts +280 -0
- package/es/utils/hooks.js +753 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/math.d.ts +1 -0
- package/es/utils/math.js +13 -2
- package/es/utils/string.d.ts +1 -0
- package/es/utils/string.js +8 -0
- package/es/utils/text.js +2 -1
- package/lib/AbstractRenderer.js +5 -0
- package/lib/camera/Camera.js +4 -4
- package/lib/css/StyleValueRegistry.d.ts +2 -0
- package/lib/css/StyleValueRegistry.js +13 -5
- package/lib/css/cssom/CSSKeywordValue.d.ts +1 -1
- package/lib/css/cssom/CSSNumericSumValue.d.ts +1 -1
- package/lib/css/cssom/CSSNumericValue.d.ts +141 -4
- package/lib/css/cssom/CSSNumericValue.js +1226 -52
- package/lib/css/cssom/CSSTransformValue.d.ts +1 -1
- package/lib/css/cssom/index.d.ts +0 -10
- package/lib/css/cssom/index.js +0 -130
- package/lib/css/parser/color.js +5 -5
- package/lib/css/parser/dimension.js +1 -3
- package/lib/css/parser/numeric.d.ts +1 -1
- package/lib/css/parser/numeric.js +7 -7
- package/lib/css/parser/path.d.ts +2 -2
- package/lib/css/parser/path.js +4 -4
- package/lib/css/parser/points.js +2 -2
- package/lib/css/parser/transform-origin.d.ts +1 -1
- package/lib/css/parser/transform-origin.js +4 -4
- package/lib/css/parser/transform.d.ts +1 -3
- package/lib/css/parser/transform.js +25 -24
- package/lib/css/properties/CSSPropertyPath.d.ts +14 -2
- package/lib/css/properties/CSSPropertyTextTransform.d.ts +2 -2
- package/lib/css/properties/CSSPropertyTransform.js +18 -20
- package/lib/display-objects/DisplayObject.js +7 -9
- package/lib/display-objects/Path.d.ts +15 -15
- package/lib/display-objects/Path.js +3 -3
- package/lib/display-objects/Polygon.d.ts +8 -1
- package/lib/display-objects/Polyline.d.ts +7 -5
- package/lib/dom/Document.js +2 -2
- package/lib/dom/Element.js +1 -3
- package/lib/dom/EventTarget.js +9 -9
- package/lib/dom/FederatedTouchEvent.d.ts +5 -3
- package/lib/plugins/CullingPlugin.d.ts +0 -1
- package/lib/plugins/CullingPlugin.js +3 -7
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/lib/plugins/DirtyCheckPlugin.js +10 -8
- package/lib/plugins/EventPlugin.d.ts +1 -1
- package/lib/plugins/EventPlugin.js +172 -156
- package/lib/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/lib/plugins/PrepareRendererPlugin.js +16 -16
- package/lib/services/EventService.d.ts +8 -0
- package/lib/services/EventService.js +274 -19
- package/lib/services/RenderingService.d.ts +17 -16
- package/lib/services/RenderingService.js +21 -20
- package/lib/services/SceneGraphService.js +3 -3
- package/lib/services/aabb/PathUpdater.d.ts +3 -3
- package/lib/services/aabb/PolylineUpdater.d.ts +3 -3
- package/lib/services/aabb/RectUpdater.js +3 -3
- package/lib/types.d.ts +5 -3
- package/lib/utils/assert.d.ts +6 -0
- package/lib/utils/assert.js +30 -0
- package/lib/utils/event.d.ts +18 -16
- package/lib/utils/hooks.d.ts +280 -0
- package/lib/utils/hooks.js +759 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/math.d.ts +1 -0
- package/lib/utils/math.js +17 -4
- package/lib/utils/string.d.ts +1 -0
- package/lib/utils/string.js +11 -0
- package/lib/utils/text.js +5 -3
- package/package.json +4 -7
- package/es/css/cssom/CSSMathInvert.d.ts +0 -14
- package/es/css/cssom/CSSMathInvert.js +0 -84
- package/es/css/cssom/CSSMathMax.d.ts +0 -17
- package/es/css/cssom/CSSMathMax.js +0 -118
- package/es/css/cssom/CSSMathMin.d.ts +0 -17
- package/es/css/cssom/CSSMathMin.js +0 -119
- package/es/css/cssom/CSSMathNegate.d.ts +0 -14
- package/es/css/cssom/CSSMathNegate.js +0 -80
- package/es/css/cssom/CSSMathProduct.d.ts +0 -16
- package/es/css/cssom/CSSMathProduct.js +0 -109
- package/es/css/cssom/CSSMathSum.d.ts +0 -17
- package/es/css/cssom/CSSMathSum.js +0 -117
- package/es/css/cssom/CSSMathValue.d.ts +0 -11
- package/es/css/cssom/CSSMathValue.js +0 -27
- package/es/css/cssom/CSSMathVariadic.d.ts +0 -9
- package/es/css/cssom/CSSMathVariadic.js +0 -44
- package/es/css/cssom/CSSNumericValueType.d.ts +0 -33
- package/es/css/cssom/CSSNumericValueType.js +0 -259
- package/es/css/cssom/CSSUnitValue.d.ts +0 -33
- package/es/css/cssom/CSSUnitValue.js +0 -252
- package/lib/css/cssom/CSSMathInvert.d.ts +0 -14
- package/lib/css/cssom/CSSMathInvert.js +0 -94
- package/lib/css/cssom/CSSMathMax.d.ts +0 -17
- package/lib/css/cssom/CSSMathMax.js +0 -128
- package/lib/css/cssom/CSSMathMin.d.ts +0 -17
- package/lib/css/cssom/CSSMathMin.js +0 -128
- package/lib/css/cssom/CSSMathNegate.d.ts +0 -14
- package/lib/css/cssom/CSSMathNegate.js +0 -89
- package/lib/css/cssom/CSSMathProduct.d.ts +0 -16
- package/lib/css/cssom/CSSMathProduct.js +0 -119
- package/lib/css/cssom/CSSMathSum.d.ts +0 -17
- package/lib/css/cssom/CSSMathSum.js +0 -129
- package/lib/css/cssom/CSSMathValue.d.ts +0 -11
- package/lib/css/cssom/CSSMathValue.js +0 -35
- package/lib/css/cssom/CSSMathVariadic.d.ts +0 -9
- package/lib/css/cssom/CSSMathVariadic.js +0 -55
- package/lib/css/cssom/CSSNumericValueType.d.ts +0 -33
- package/lib/css/cssom/CSSNumericValueType.js +0 -272
- package/lib/css/cssom/CSSUnitValue.d.ts +0 -33
- package/lib/css/cssom/CSSUnitValue.js +0 -267
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CSSMathNegate = void 0;
|
|
7
|
-
|
|
8
|
-
var _tslib = require("tslib");
|
|
9
|
-
|
|
10
|
-
var _CSSMathValue = require("./CSSMathValue");
|
|
11
|
-
|
|
12
|
-
var _ = require(".");
|
|
13
|
-
|
|
14
|
-
var CSSMathNegate =
|
|
15
|
-
/** @class */
|
|
16
|
-
function (_super) {
|
|
17
|
-
(0, _tslib.__extends)(CSSMathNegate, _super);
|
|
18
|
-
|
|
19
|
-
function CSSMathNegate(value, type) {
|
|
20
|
-
var _this = _super.call(this, type) || this;
|
|
21
|
-
|
|
22
|
-
_this.value = value;
|
|
23
|
-
_this.operator = 'negate';
|
|
24
|
-
return _this;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
CSSMathNegate.create = function (value) {
|
|
28
|
-
return new CSSMathNegate(value, value.type_);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
CSSMathNegate.prototype.clone = function () {
|
|
32
|
-
return new CSSMathNegate(this.value, this.type_);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
CSSMathNegate.prototype.getType = function () {
|
|
36
|
-
return _.CSSStyleValueType.kNegateType;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
CSSMathNegate.prototype.equals = function (other) {
|
|
40
|
-
if (other.getType() !== _.CSSStyleValueType.kNegateType) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var other_invert = other;
|
|
45
|
-
return this.value.equals(other_invert.value);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
CSSMathNegate.prototype.sumValue = function () {
|
|
49
|
-
var sum = this.value.sumValue();
|
|
50
|
-
|
|
51
|
-
if (sum.length === 0) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
sum.forEach(function (term) {
|
|
56
|
-
term.value *= -1;
|
|
57
|
-
});
|
|
58
|
-
return sum;
|
|
59
|
-
}; // toCalcExpressionNode(): CSSMathExpressionNode {
|
|
60
|
-
// const right_side = this.value.toCalcExpressionNode();
|
|
61
|
-
// if (!right_side) {
|
|
62
|
-
// return null;
|
|
63
|
-
// }
|
|
64
|
-
// // return CSSMathExpressionOperation::CreateArithmeticOperationSimplified(
|
|
65
|
-
// // CSSMathExpressionNumericLiteral::Create(
|
|
66
|
-
// // -1, CSSPrimitiveValue::UnitType::kNumber),
|
|
67
|
-
// // right_side, CSSMathOperator::kMultiply);
|
|
68
|
-
// }
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
CSSMathNegate.prototype.buildCSSText = function (nested, paren_less, result) {
|
|
72
|
-
if (paren_less == _.ParenLess.kNo) {
|
|
73
|
-
result += nested === _.Nested.kYes ? '(' : 'calc(';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
result += '-';
|
|
77
|
-
result = this.value.buildCSSText(_.Nested.kYes, _.ParenLess.kNo, result);
|
|
78
|
-
|
|
79
|
-
if (paren_less === _.ParenLess.kNo) {
|
|
80
|
-
result += ')';
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return result;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
return CSSMathNegate;
|
|
87
|
-
}(_CSSMathValue.CSSMathValue);
|
|
88
|
-
|
|
89
|
-
exports.CSSMathNegate = CSSMathNegate;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { CSSNumericValue, CSSNumericSumValue, UnitMap } from '.';
|
|
2
|
-
import { CSSMathVariadic } from './CSSMathVariadic';
|
|
3
|
-
import { CSSStyleValueType, Nested, ParenLess } from '.';
|
|
4
|
-
/**
|
|
5
|
-
* Represents the product of one or more CSSNumericValues.
|
|
6
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#cssmathproduct
|
|
7
|
-
*/
|
|
8
|
-
export declare class CSSMathProduct extends CSSMathVariadic {
|
|
9
|
-
static create(values: CSSNumericValue[]): CSSMathProduct;
|
|
10
|
-
static multiplyUnitMaps(a: UnitMap, b: UnitMap): UnitMap;
|
|
11
|
-
operator: string;
|
|
12
|
-
clone(): CSSMathProduct;
|
|
13
|
-
getType(): CSSStyleValueType;
|
|
14
|
-
sumValue(): CSSNumericSumValue;
|
|
15
|
-
buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string;
|
|
16
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CSSMathProduct = void 0;
|
|
7
|
-
|
|
8
|
-
var _tslib = require("tslib");
|
|
9
|
-
|
|
10
|
-
var _utils = require("../../utils");
|
|
11
|
-
|
|
12
|
-
var _CSSMathVariadic = require("./CSSMathVariadic");
|
|
13
|
-
|
|
14
|
-
var _ = require(".");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Represents the product of one or more CSSNumericValues.
|
|
18
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#cssmathproduct
|
|
19
|
-
*/
|
|
20
|
-
var CSSMathProduct =
|
|
21
|
-
/** @class */
|
|
22
|
-
function (_super) {
|
|
23
|
-
(0, _tslib.__extends)(CSSMathProduct, _super);
|
|
24
|
-
|
|
25
|
-
function CSSMathProduct() {
|
|
26
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
27
|
-
|
|
28
|
-
_this.operator = 'product';
|
|
29
|
-
return _this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
CSSMathProduct.create = function (values) {
|
|
33
|
-
var error = false;
|
|
34
|
-
var finalType = (0, _.typeCheck)(values, _.CSSNumericValueType.multiply, error);
|
|
35
|
-
return error ? null : new CSSMathProduct(values, finalType);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
CSSMathProduct.multiplyUnitMaps = function (a, b) {
|
|
39
|
-
Object.keys(b).forEach(function (key) {
|
|
40
|
-
(0, _utils.DCHECK_NE)(b[key].value, 0);
|
|
41
|
-
var old_value = key in a ? a[key].value : 0;
|
|
42
|
-
|
|
43
|
-
if (old_value + b[key].value === 0) {
|
|
44
|
-
delete a[key];
|
|
45
|
-
} else {
|
|
46
|
-
a[key] = old_value + b[key].value;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return a;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
CSSMathProduct.prototype.clone = function () {
|
|
53
|
-
return new CSSMathProduct(this.values, this.type_);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
CSSMathProduct.prototype.getType = function () {
|
|
57
|
-
return _.CSSStyleValueType.kProductType;
|
|
58
|
-
}; // toCalcExpressionNode() {
|
|
59
|
-
// return this.toCalcExporessionNodeForVariadic(CSSMathOperator.kMultiply);
|
|
60
|
-
// }
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
CSSMathProduct.prototype.sumValue = function () {
|
|
64
|
-
var sum = [{
|
|
65
|
-
value: 1,
|
|
66
|
-
units: {}
|
|
67
|
-
}];
|
|
68
|
-
this.numericValues().forEach(function (value) {
|
|
69
|
-
var child_sum = value.sumValue();
|
|
70
|
-
|
|
71
|
-
if (!child_sum.length) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
var new_sum = [];
|
|
76
|
-
sum.forEach(function (a) {
|
|
77
|
-
child_sum.forEach(function (b) {
|
|
78
|
-
new_sum.push({
|
|
79
|
-
value: a.value * b.value,
|
|
80
|
-
units: CSSMathProduct.multiplyUnitMaps(a.units, b.units)
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
sum = new_sum;
|
|
85
|
-
});
|
|
86
|
-
return sum;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
CSSMathProduct.prototype.buildCSSText = function (nested, paren_less, result) {
|
|
90
|
-
if (paren_less == _.ParenLess.kNo) {
|
|
91
|
-
result += nested === _.Nested.kYes ? '(' : 'calc(';
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
var values = this.numericValues();
|
|
95
|
-
result = values[0].buildCSSText(_.Nested.kYes, _.ParenLess.kNo, result);
|
|
96
|
-
|
|
97
|
-
for (var i = 1; i < values.length; i++) {
|
|
98
|
-
var arg = values[i];
|
|
99
|
-
|
|
100
|
-
if (arg.getType() === _.CSSStyleValueType.kInvertType) {
|
|
101
|
-
result += ' / ';
|
|
102
|
-
result = arg.value.buildCSSText(_.Nested.kYes, _.ParenLess.kNo, result);
|
|
103
|
-
} else {
|
|
104
|
-
result += ' * ';
|
|
105
|
-
result = arg.buildCSSText(_.Nested.kYes, _.ParenLess.kNo, result);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (paren_less === _.ParenLess.kNo) {
|
|
110
|
-
result += ')';
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return result;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
return CSSMathProduct;
|
|
117
|
-
}(_CSSMathVariadic.CSSMathVariadic);
|
|
118
|
-
|
|
119
|
-
exports.CSSMathProduct = CSSMathProduct;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CSSNumericValue, CSSNumericSumValue, UnitMap } from '.';
|
|
2
|
-
import { CSSMathVariadic } from './CSSMathVariadic';
|
|
3
|
-
import { CSSStyleValueType, CSSNumericValueType, Nested, ParenLess } from '.';
|
|
4
|
-
/**
|
|
5
|
-
* Represents the sum of one or more CSSNumericValues.
|
|
6
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
|
|
7
|
-
*/
|
|
8
|
-
export declare class CSSMathSum extends CSSMathVariadic {
|
|
9
|
-
static create(values: CSSNumericValue[]): CSSMathSum;
|
|
10
|
-
static numericTypeFromUnitMap(units: UnitMap): CSSNumericValueType;
|
|
11
|
-
static canCreateNumericTypeFromSumValue(sum: CSSNumericSumValue): boolean;
|
|
12
|
-
operator: string;
|
|
13
|
-
clone(): CSSMathSum;
|
|
14
|
-
getType(): CSSStyleValueType;
|
|
15
|
-
sumValue(): CSSNumericSumValue;
|
|
16
|
-
buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string;
|
|
17
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CSSMathSum = void 0;
|
|
7
|
-
|
|
8
|
-
var _tslib = require("tslib");
|
|
9
|
-
|
|
10
|
-
var _utils = require("../../utils");
|
|
11
|
-
|
|
12
|
-
var _CSSMathVariadic = require("./CSSMathVariadic");
|
|
13
|
-
|
|
14
|
-
var _ = require(".");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Represents the sum of one or more CSSNumericValues.
|
|
18
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
|
|
19
|
-
*/
|
|
20
|
-
var CSSMathSum =
|
|
21
|
-
/** @class */
|
|
22
|
-
function (_super) {
|
|
23
|
-
(0, _tslib.__extends)(CSSMathSum, _super);
|
|
24
|
-
|
|
25
|
-
function CSSMathSum() {
|
|
26
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
27
|
-
|
|
28
|
-
_this.operator = 'sum';
|
|
29
|
-
return _this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
CSSMathSum.create = function (values) {
|
|
33
|
-
var error = false;
|
|
34
|
-
var finalType = (0, _.typeCheck)(values, _.CSSNumericValueType.add, error);
|
|
35
|
-
return error ? null : new CSSMathSum(values, finalType);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
CSSMathSum.numericTypeFromUnitMap = function (units) {
|
|
39
|
-
var type = new _.CSSNumericValueType();
|
|
40
|
-
Object.keys(units).forEach(function (key) {
|
|
41
|
-
var exp = units[key];
|
|
42
|
-
var error = false;
|
|
43
|
-
type = _.CSSNumericValueType.multiply(type, new _.CSSNumericValueType(Number(key), exp), error);
|
|
44
|
-
(0, _utils.DCHECK)(!error);
|
|
45
|
-
});
|
|
46
|
-
return type;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
CSSMathSum.canCreateNumericTypeFromSumValue = function (sum) {
|
|
50
|
-
var _this = this;
|
|
51
|
-
|
|
52
|
-
(0, _utils.DCHECK)(!!sum.length);
|
|
53
|
-
var first_type = this.numericTypeFromUnitMap(sum[0].units);
|
|
54
|
-
return sum.every(function (term) {
|
|
55
|
-
var error = false;
|
|
56
|
-
|
|
57
|
-
_.CSSNumericValueType.add(first_type, _this.numericTypeFromUnitMap(term.units), error);
|
|
58
|
-
|
|
59
|
-
return !error;
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
CSSMathSum.prototype.clone = function () {
|
|
64
|
-
return new CSSMathSum(this.values, this.type_);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
CSSMathSum.prototype.getType = function () {
|
|
68
|
-
return _.CSSStyleValueType.kSumType;
|
|
69
|
-
}; // toCalcExpressionNode() {
|
|
70
|
-
// return this.toCalcExporessionNodeForVariadic(CSSMathOperator.kAdd);
|
|
71
|
-
// }
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
CSSMathSum.prototype.sumValue = function () {
|
|
75
|
-
var sum = [];
|
|
76
|
-
this.numericValues().forEach(function (value) {
|
|
77
|
-
var child_sum = value.sumValue();
|
|
78
|
-
|
|
79
|
-
if (!child_sum.length) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
child_sum.forEach(function (term) {
|
|
84
|
-
var index = sum.findIndex(function (s) {
|
|
85
|
-
return JSON.stringify(s.units) === JSON.stringify(term.units);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
if (index === -1) {
|
|
89
|
-
sum.push((0, _tslib.__assign)({}, term));
|
|
90
|
-
} else {
|
|
91
|
-
sum[index].value += term.value;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
if (!CSSMathSum.canCreateNumericTypeFromSumValue(sum)) return null;
|
|
96
|
-
return sum;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
CSSMathSum.prototype.buildCSSText = function (nested, paren_less, result) {
|
|
100
|
-
if (paren_less == _.ParenLess.kNo) {
|
|
101
|
-
result += nested === _.Nested.kYes ? '(' : 'calc(';
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
var values = this.numericValues();
|
|
105
|
-
result = values[0].buildCSSText(_.Nested.kYes, _.ParenLess.kNo, result);
|
|
106
|
-
|
|
107
|
-
for (var i = 1; i < values.length; i++) {
|
|
108
|
-
var arg = values[i];
|
|
109
|
-
|
|
110
|
-
if (arg.getType() === _.CSSStyleValueType.kNegateType) {
|
|
111
|
-
result += ' - ';
|
|
112
|
-
result = arg.value.buildCSSText(_.Nested.kYes, _.ParenLess.kNo, result);
|
|
113
|
-
} else {
|
|
114
|
-
result += ' + ';
|
|
115
|
-
result = arg.buildCSSText(_.Nested.kYes, _.ParenLess.kNo, result);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (paren_less === _.ParenLess.kNo) {
|
|
120
|
-
result += ')';
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return result;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
return CSSMathSum;
|
|
127
|
-
}(_CSSMathVariadic.CSSMathVariadic);
|
|
128
|
-
|
|
129
|
-
exports.CSSMathSum = CSSMathSum;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { CSSNumericValue } from './CSSNumericValue';
|
|
2
|
-
/**
|
|
3
|
-
* The CSSMathValue interface of the CSS_Object_Model a base class for classes representing complex numeric values.
|
|
4
|
-
*
|
|
5
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSMathValue
|
|
6
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_math_value.idl
|
|
7
|
-
*/
|
|
8
|
-
export declare abstract class CSSMathValue extends CSSNumericValue {
|
|
9
|
-
abstract operator: string;
|
|
10
|
-
isUnitValue(): boolean;
|
|
11
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CSSMathValue = void 0;
|
|
7
|
-
|
|
8
|
-
var _tslib = require("tslib");
|
|
9
|
-
|
|
10
|
-
var _CSSNumericValue = require("./CSSNumericValue");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The CSSMathValue interface of the CSS_Object_Model a base class for classes representing complex numeric values.
|
|
14
|
-
*
|
|
15
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSMathValue
|
|
16
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_math_value.idl
|
|
17
|
-
*/
|
|
18
|
-
var CSSMathValue =
|
|
19
|
-
/** @class */
|
|
20
|
-
function (_super) {
|
|
21
|
-
(0, _tslib.__extends)(CSSMathValue, _super);
|
|
22
|
-
|
|
23
|
-
function CSSMathValue() {
|
|
24
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
-
} // From CSSNumericValue
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
CSSMathValue.prototype.isUnitValue = function () {
|
|
29
|
-
return false;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return CSSMathValue;
|
|
33
|
-
}(_CSSNumericValue.CSSNumericValue);
|
|
34
|
-
|
|
35
|
-
exports.CSSMathValue = CSSMathValue;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CSSMathValue } from './CSSMathValue';
|
|
2
|
-
import type { CSSNumericValue, CSSNumericValueType } from '.';
|
|
3
|
-
export declare function typeCheck(values: CSSNumericValue[], op: Function, error: boolean): CSSNumericValueType;
|
|
4
|
-
export declare abstract class CSSMathVariadic extends CSSMathValue {
|
|
5
|
-
values: CSSNumericValue[];
|
|
6
|
-
constructor(values: CSSNumericValue[], type: CSSNumericValueType);
|
|
7
|
-
numericValues(): CSSNumericValue[];
|
|
8
|
-
equals(other: CSSNumericValue): any;
|
|
9
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CSSMathVariadic = void 0;
|
|
7
|
-
exports.typeCheck = typeCheck;
|
|
8
|
-
|
|
9
|
-
var _tslib = require("tslib");
|
|
10
|
-
|
|
11
|
-
var _CSSMathValue = require("./CSSMathValue");
|
|
12
|
-
|
|
13
|
-
function typeCheck(values, op, error) {
|
|
14
|
-
error = false;
|
|
15
|
-
var final_type = values[0].type_;
|
|
16
|
-
|
|
17
|
-
for (var i = 1; i < values.length; i++) {
|
|
18
|
-
final_type = op(final_type, values[i].type_, error);
|
|
19
|
-
if (error) return final_type;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return final_type;
|
|
23
|
-
} // Represents an arithmetic operation with one or more CSSNumericValues.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var CSSMathVariadic =
|
|
27
|
-
/** @class */
|
|
28
|
-
function (_super) {
|
|
29
|
-
(0, _tslib.__extends)(CSSMathVariadic, _super);
|
|
30
|
-
|
|
31
|
-
function CSSMathVariadic(values, type) {
|
|
32
|
-
var _this = _super.call(this, type) || this;
|
|
33
|
-
|
|
34
|
-
_this.values = values;
|
|
35
|
-
return _this;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
CSSMathVariadic.prototype.numericValues = function () {
|
|
39
|
-
return this.values;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
CSSMathVariadic.prototype.equals = function (other) {
|
|
43
|
-
if (this.getType() !== other.getType()) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return this.values.every(function (value, i) {
|
|
48
|
-
return value.equals(other.values[i]);
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return CSSMathVariadic;
|
|
53
|
-
}(_CSSMathValue.CSSMathValue);
|
|
54
|
-
|
|
55
|
-
exports.CSSMathVariadic = CSSMathVariadic;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { UnitType } from '.';
|
|
2
|
-
export declare enum BaseType {
|
|
3
|
-
kLength = 0,
|
|
4
|
-
kAngle = 1,
|
|
5
|
-
kTime = 2,
|
|
6
|
-
kFrequency = 3,
|
|
7
|
-
kResolution = 4,
|
|
8
|
-
kFlex = 5,
|
|
9
|
-
kPercent = 6,
|
|
10
|
-
kNumBaseTypes = 7
|
|
11
|
-
}
|
|
12
|
-
export declare function unitTypeToBaseType(unit: UnitType): BaseType.kLength | BaseType.kAngle | BaseType.kTime | BaseType.kFrequency | BaseType.kResolution | BaseType.kFlex | BaseType.kPercent;
|
|
13
|
-
export declare function baseTypeToString(baseType: BaseType): "" | "percent" | "length" | "angle" | "time" | "frequency" | "resolution" | "flex";
|
|
14
|
-
export declare class CSSNumericValueType {
|
|
15
|
-
private exponents;
|
|
16
|
-
private numNonZeroEntries;
|
|
17
|
-
percentHint: BaseType;
|
|
18
|
-
hasPercentHint: boolean;
|
|
19
|
-
constructor(unit?: UnitType, exponent?: number);
|
|
20
|
-
applyPercentHint(hint: BaseType): void;
|
|
21
|
-
hasNonZeroEntries(): boolean;
|
|
22
|
-
isOnlyNonZeroEntry(baseType: BaseType, value: number): boolean;
|
|
23
|
-
exponent(type: BaseType): number;
|
|
24
|
-
setExponent(type: BaseType, newValue: number): void;
|
|
25
|
-
static negateExponents(type: CSSNumericValueType): CSSNumericValueType;
|
|
26
|
-
matchesBaseType(baseType: BaseType): boolean;
|
|
27
|
-
matchesPercentage(): boolean;
|
|
28
|
-
matchesBaseTypePercentage(baseType: BaseType): boolean;
|
|
29
|
-
matchesNumber(): boolean;
|
|
30
|
-
matchesNumberPercentage(): boolean;
|
|
31
|
-
static add(type1: CSSNumericValueType, type2: CSSNumericValueType, error: boolean): CSSNumericValueType;
|
|
32
|
-
static multiply(type1: CSSNumericValueType, type2: CSSNumericValueType, error: boolean): CSSNumericValueType;
|
|
33
|
-
}
|